Análisis Exploratorio
Descripción de Variables
## Id MSSubClass MSZoning LotFrontage
## Min. : 1.0 Min. : 20.0 Length:1460 Min. : 21.00
## 1st Qu.: 365.8 1st Qu.: 20.0 Class :character 1st Qu.: 59.00
## Median : 730.5 Median : 50.0 Mode :character Median : 69.00
## Mean : 730.5 Mean : 56.9 Mean : 70.05
## 3rd Qu.:1095.2 3rd Qu.: 70.0 3rd Qu.: 80.00
## Max. :1460.0 Max. :190.0 Max. :313.00
## NA's :259
## LotArea Street Alley LotShape
## Min. : 1300 Length:1460 Length:1460 Length:1460
## 1st Qu.: 7554 Class :character Class :character Class :character
## Median : 9478 Mode :character Mode :character Mode :character
## Mean : 10517
## 3rd Qu.: 11602
## Max. :215245
##
## LandContour Utilities LotConfig LandSlope
## Length:1460 Length:1460 Length:1460 Length:1460
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Neighborhood Condition1 Condition2 BldgType
## Length:1460 Length:1460 Length:1460 Length:1460
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## HouseStyle OverallQual OverallCond YearBuilt
## Length:1460 Min. : 1.000 Min. :1.000 Min. :1872
## Class :character 1st Qu.: 5.000 1st Qu.:5.000 1st Qu.:1954
## Mode :character Median : 6.000 Median :5.000 Median :1973
## Mean : 6.099 Mean :5.575 Mean :1971
## 3rd Qu.: 7.000 3rd Qu.:6.000 3rd Qu.:2000
## Max. :10.000 Max. :9.000 Max. :2010
##
## YearRemodAdd RoofStyle RoofMatl Exterior1st
## Min. :1950 Length:1460 Length:1460 Length:1460
## 1st Qu.:1967 Class :character Class :character Class :character
## Median :1994 Mode :character Mode :character Mode :character
## Mean :1985
## 3rd Qu.:2004
## Max. :2010
##
## Exterior2nd MasVnrType MasVnrArea ExterQual
## Length:1460 Length:1460 Min. : 0.0 Length:1460
## Class :character Class :character 1st Qu.: 0.0 Class :character
## Mode :character Mode :character Median : 0.0 Mode :character
## Mean : 103.7
## 3rd Qu.: 166.0
## Max. :1600.0
## NA's :8
## ExterCond Foundation BsmtQual BsmtCond
## Length:1460 Length:1460 Length:1460 Length:1460
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## BsmtExposure BsmtFinType1 BsmtFinSF1 BsmtFinType2
## Length:1460 Length:1460 Min. : 0.0 Length:1460
## Class :character Class :character 1st Qu.: 0.0 Class :character
## Mode :character Mode :character Median : 383.5 Mode :character
## Mean : 443.6
## 3rd Qu.: 712.2
## Max. :5644.0
##
## BsmtFinSF2 BsmtUnfSF TotalBsmtSF Heating
## Min. : 0.00 Min. : 0.0 Min. : 0.0 Length:1460
## 1st Qu.: 0.00 1st Qu.: 223.0 1st Qu.: 795.8 Class :character
## Median : 0.00 Median : 477.5 Median : 991.5 Mode :character
## Mean : 46.55 Mean : 567.2 Mean :1057.4
## 3rd Qu.: 0.00 3rd Qu.: 808.0 3rd Qu.:1298.2
## Max. :1474.00 Max. :2336.0 Max. :6110.0
##
## HeatingQC CentralAir Electrical X1stFlrSF
## Length:1460 Length:1460 Length:1460 Min. : 334
## Class :character Class :character Class :character 1st Qu.: 882
## Mode :character Mode :character Mode :character Median :1087
## Mean :1163
## 3rd Qu.:1391
## Max. :4692
##
## X2ndFlrSF LowQualFinSF GrLivArea BsmtFullBath
## Min. : 0 Min. : 0.000 Min. : 334 Min. :0.0000
## 1st Qu.: 0 1st Qu.: 0.000 1st Qu.:1130 1st Qu.:0.0000
## Median : 0 Median : 0.000 Median :1464 Median :0.0000
## Mean : 347 Mean : 5.845 Mean :1515 Mean :0.4253
## 3rd Qu.: 728 3rd Qu.: 0.000 3rd Qu.:1777 3rd Qu.:1.0000
## Max. :2065 Max. :572.000 Max. :5642 Max. :3.0000
##
## BsmtHalfBath FullBath HalfBath BedroomAbvGr
## Min. :0.00000 Min. :0.000 Min. :0.0000 Min. :0.000
## 1st Qu.:0.00000 1st Qu.:1.000 1st Qu.:0.0000 1st Qu.:2.000
## Median :0.00000 Median :2.000 Median :0.0000 Median :3.000
## Mean :0.05753 Mean :1.565 Mean :0.3829 Mean :2.866
## 3rd Qu.:0.00000 3rd Qu.:2.000 3rd Qu.:1.0000 3rd Qu.:3.000
## Max. :2.00000 Max. :3.000 Max. :2.0000 Max. :8.000
##
## KitchenAbvGr KitchenQual TotRmsAbvGrd Functional
## Min. :0.000 Length:1460 Min. : 2.000 Length:1460
## 1st Qu.:1.000 Class :character 1st Qu.: 5.000 Class :character
## Median :1.000 Mode :character Median : 6.000 Mode :character
## Mean :1.047 Mean : 6.518
## 3rd Qu.:1.000 3rd Qu.: 7.000
## Max. :3.000 Max. :14.000
##
## Fireplaces FireplaceQu GarageType GarageYrBlt
## Min. :0.000 Length:1460 Length:1460 Min. :1900
## 1st Qu.:0.000 Class :character Class :character 1st Qu.:1961
## Median :1.000 Mode :character Mode :character Median :1980
## Mean :0.613 Mean :1979
## 3rd Qu.:1.000 3rd Qu.:2002
## Max. :3.000 Max. :2010
## NA's :81
## GarageFinish GarageCars GarageArea GarageQual
## Length:1460 Min. :0.000 Min. : 0.0 Length:1460
## Class :character 1st Qu.:1.000 1st Qu.: 334.5 Class :character
## Mode :character Median :2.000 Median : 480.0 Mode :character
## Mean :1.767 Mean : 473.0
## 3rd Qu.:2.000 3rd Qu.: 576.0
## Max. :4.000 Max. :1418.0
##
## GarageCond PavedDrive WoodDeckSF OpenPorchSF
## Length:1460 Length:1460 Min. : 0.00 Min. : 0.00
## Class :character Class :character 1st Qu.: 0.00 1st Qu.: 0.00
## Mode :character Mode :character Median : 0.00 Median : 25.00
## Mean : 94.24 Mean : 46.66
## 3rd Qu.:168.00 3rd Qu.: 68.00
## Max. :857.00 Max. :547.00
##
## EnclosedPorch X3SsnPorch ScreenPorch PoolArea
## Min. : 0.00 Min. : 0.00 Min. : 0.00 Min. : 0.000
## 1st Qu.: 0.00 1st Qu.: 0.00 1st Qu.: 0.00 1st Qu.: 0.000
## Median : 0.00 Median : 0.00 Median : 0.00 Median : 0.000
## Mean : 21.95 Mean : 3.41 Mean : 15.06 Mean : 2.759
## 3rd Qu.: 0.00 3rd Qu.: 0.00 3rd Qu.: 0.00 3rd Qu.: 0.000
## Max. :552.00 Max. :508.00 Max. :480.00 Max. :738.000
##
## PoolQC Fence MiscFeature MiscVal
## Length:1460 Length:1460 Length:1460 Min. : 0.00
## Class :character Class :character Class :character 1st Qu.: 0.00
## Mode :character Mode :character Mode :character Median : 0.00
## Mean : 43.49
## 3rd Qu.: 0.00
## Max. :15500.00
##
## MoSold YrSold SaleType SaleCondition
## Min. : 1.000 Min. :2006 Length:1460 Length:1460
## 1st Qu.: 5.000 1st Qu.:2007 Class :character Class :character
## Median : 6.000 Median :2008 Mode :character Mode :character
## Mean : 6.322 Mean :2008
## 3rd Qu.: 8.000 3rd Qu.:2009
## Max. :12.000 Max. :2010
##
## SalePrice
## Min. : 34900
## 1st Qu.:129975
## Median :163000
## Mean :180921
## 3rd Qu.:214000
## Max. :755000
##
Para este dataset contamos con las siguientes variables:
Variables Cuantitativas
Discretas
- Bedroom: Número de habitaciones sobre el nivel del
sótano.
- Kitchen: Número de cocinas.
- TotRmsAbvGrd: Total de habitaciones sobre el nivel
del suelo (excluye baños).
- Fireplaces: Número de chimeneas.
- GarageCars: Tamaño del garaje en capacidad de
autos.
- BsmtFullBath: Baños completos en el sótano.
- BsmtHalfBath: Medios baños en el sótano.
- FullBath: Baños completos sobre el nivel del
suelo.
- HalfBath: Medios baños sobre el nivel del
suelo.
- MoSold: Mes de venta.
- YrSold: Año de venta.
Continuas
- SalePrice: Precio de venta de la propiedad en
dólares.
- LotFrontage: Pies lineales de calle conectados a la
propiedad.
- LotArea: Tamaño del terreno en pies
cuadrados.
- MasVnrArea: Área de revestimiento de mampostería en
pies cuadrados.
- BsmtFinSF1: Pies cuadrados terminados de tipo 1 en
el sótano.
- BsmtFinSF2: Pies cuadrados terminados de tipo 2 en
el sótano.
- BsmtUnfSF: Pies cuadrados sin terminar del
sótano.
- TotalBsmtSF: Pies cuadrados totales del
sótano.
- 1stFlrSF: Pies cuadrados del primer piso.
- 2ndFlrSF: Pies cuadrados del segundo piso.
- LowQualFinSF: Pies cuadrados terminados de baja
calidad (todos los pisos).
- GrLivArea: Pies cuadrados de área habitable sobre
el nivel del suelo.
- GarageArea: Tamaño del garaje en pies
cuadrados.
- WoodDeckSF: Área de la terraza de madera en pies
cuadrados.
- OpenPorchSF: Área del porche abierto en pies
cuadrados.
- EnclosedPorch: Área del porche cerrado en pies
cuadrados.
- 3SsnPorch: Área del porche de tres estaciones en
pies cuadrados.
- ScreenPorch: Área del porche con malla en pies
cuadrados.
- PoolArea: Área de la piscina en pies
cuadrados.
- MiscVal: Valor en dólares de la característica
adicional.
- GarageYrBlt: Año en que se construyó el
garaje.
- YearBuilt: Año de construcción original.
- YearRemodAdd: Año de remodelación.
Variables Cualitativas
Nominales
- MSZoning: Clasificación general de
zonificación.
- Street: Tipo de acceso por carretera.
- Alley: Tipo de acceso por callejón.
- LandContour: Nivelación del terreno.
- Utilities: Tipo de servicios públicos
disponibles.
- LotConfig: Configuración del terreno.
- Neighborhood: Ubicación física dentro de la ciudad
de Ames.
- Condition1: Proximidad a una carretera principal o
ferrocarril.
- Condition2: Proximidad a una carretera principal o
ferrocarril (si hay un segundo presente).
- BldgType: Tipo de vivienda.
- HouseStyle: Estilo de vivienda.
- RoofStyle: Tipo de techo.
- RoofMatl: Material del techo.
- Exterior1st: Revestimiento exterior de la
casa.
- Exterior2nd: Revestimiento exterior de la casa (si
hay más de un material).
- MasVnrType: Tipo de revestimiento de
mampostería.
- Foundation: Tipo de cimentación.
- Heating: Tipo de calefacción.
- CentralAir: Aire acondicionado central
(Sí/No).
- Electrical: Sistema eléctrico.
- GarageType: Ubicación del garaje.
- GarageFinish: Acabado interior del garaje.
- PavedDrive: Entrada pavimentada.
- Fence: Calidad de la cerca.
- MiscFeature: Característica adicional no cubierta
en otras categorías.
- SaleType: Tipo de venta.
- SaleCondition: Condición de la venta.
Ordinales
- MSSubClass: Clase del edificio (número representa
diferentes categorías).
- LotShape: Forma general de la propiedad (Regular,
Irregular, etc.).
- LandSlope: Pendiente del terreno (Nivel, Suave,
Empinada).
- OverallQual: Calidad general de los materiales y
acabados (escala de 1 a 10).
- OverallCond: Calificación general del estado de la
vivienda (escala de 1 a 10).
- ExterQual: Calidad del material exterior (Escala:
Excelente, Buena, Regular, Pobre).
- ExterCond: Condición actual del material en el
exterior (Escala similar a ExterQual).
- BsmtQual: Altura del sótano (Escala de
calidad).
- BsmtCond: Condición general del sótano.
- BsmtExposure: Paredes del sótano con acceso al
exterior o jardín.
- BsmtFinType1: Calidad del área terminada del
sótano.
- BsmtFinType2: Calidad del segundo área terminada
del sótano.
- HeatingQC: Calidad y condición de la
calefacción.
- KitchenQual: Calidad de la cocina.
- Functional: Calificación de funcionalidad de la
vivienda.
- FireplaceQu: Calidad de la chimenea.
- GarageQual: Calidad del garaje.
- GarageCond: Condición del garaje.
- PoolQC: Calidad de la piscina.
Análisis Exploratorio
¿Cuál es el comportamiento de la variable SalesPrice?
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
El histograma nos dice que es probable que tenga forma normal aunque increíblemente cesgada hacia la derecha. La línea verde representa la media, la línea morada de la derecha es 3 desviaciones estándar después de la media, la línea morada de la izquierda es 1.5 desviaciones estándar antes de la media.
La prueba de Shapiro (la cual la podemos utilizar puesto nuestros datos no tienen más de 5000 observaciones) nos dice que:
##
## Shapiro-Wilk normality test
##
## data: training_data$SalePrice
## W = 0.86967, p-value < 2.2e-16
## Warning in ks.test.default(training_data$SalePrice, "pnorm",
## mean(training_data$SalePrice), : ties should not be present for the one-sample
## Kolmogorov-Smirnov test
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: training_data$SalePrice
## D = 0.12369, p-value < 2.2e-16
## alternative hypothesis: two-sided
Además también confirmamos con la prueba de Kolmogorov-Smirnov y ambas indican que la distribución de SalesPrice es normal.
Por lo tanto obtenemos la desviación estándar de:
sd(training_data$SalePrice).
¿Cuáles son los condominios con casas más caras/baratas?
Los condominios con las casa más caras son:
## Warning: package 'dplyr' was built under R version 4.4.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
El gráfico de arriba nos muestra el promedio por condominio de SalesPrice de las casas cuyo precio es mayor a 3 veces la desviación estándar. Esto nos ayuda a determinar qué condominios son los que contienen las casas más caras.
Los condominios con casas más baratas son:
Este gráfico funcion de forma similar al anterior, muestra el promedio de SalePrice por condominio de todas las casas cuyo precio es menor o igual a 1.5 desviaciones estándar debajo de la media.
¿Cuál es la distribución de los tipos de ventas realizados?
La gran mayoría de ventas son del tipo WD (Warranty Deed - Conventional) y por un gran márgen, para poder analizar mejor los datos podemos ver la distribución ignorando el tipo WD:
Dentro de los tipos de venta niche: ConLD, ConLI, ConLw, CWD, Oth y Con son masmoenos usadas en la misma frecuencia mientras que New (Home just constructed and sold) es usada con gran dominancia seguida en segundo lugar por COD (Court Officer Deed/Estate).
¿Cómo se compara el tamaño de la planta baja con el SalePrice?
## `geom_smooth()` using formula = 'y ~ x'
La gráfica intenta encontrar una relación entre ambas variables sin
embargo esta no resulta muy conclusiva ya que solamente tienen una
correlación de correlacion. La cual indica una relación
pero no es determinante.
¿El tipo de fundación de la casa afecta su precio?
Como se puede ver por el diagrama, si hay una clara relación entre las construcciones realizadas por PConc y a tener un precio de venta más elevado en promedio lo que nos indica que esta variable pordría ser una muy buena predictora del precio de una casa.
¿Cuáles son las características más correlacionadas con el precio de venta?
Se puede ver cuales son las variables que más se correlacionan con el precio de venta. Esto nos inidica cuales son las consideraciones a tomar en cuenta al momento de valuar una propiedad; aumentandolo o decreciendolo, según sea el caso.
¿Cómo varia el precio de venta según el vecindario?
En el gráfico anterior podemos ver como se distribuye el precio de venta en cada condominio. Se puede ver que hay condominios que tienen una variedad de precios bastante limitada como en los condominios de Blueste o NPlVIII. La presencia de datos atípicos en algunos condominios nos puede indicar que existen casas en esos respectivos condominios que por ciertas razones estan valuadas mejor que el resto. Una mayor variedad de precios de venta indica que el condominio posee casas con distintas condiciones (variables listadas en la pregunta anterior) que hacen variar ese precio.
¿Cómo afecta la antigüedad de la vivienda a precio de venta?
## `geom_smooth()` using formula = 'y ~ x'
En este gráfico de dispersión se analiza en precio de las 10 viviendas más antiguas junto con las 10 más nuevas. Cómo se puede apreciar no existe una relación clara entre el precio de venta y la antigüedad de la casa. Implicando que la antigüedad de la casa no influye en su precio de venta.
¿Existen patrones estacionales en las ventas de propiedades?
Según se puede ver en la distribución de la cantidad de casas vendidas por mes, se puede ver que la mayor cantidad de casas se vende a lo largo de la mitad del año: Mayo, Junio y Julio. Indicando esto como los mejores meses para poder vender casas.
¿Cómo varian las calificaciones de calidad y condición según el tipo de fachada y su material?
## # A tibble: 37 × 4
## Exterior1st ExterQual mean_overallqual mean_overallcond
## <fct> <fct> <dbl> <dbl>
## 1 AsbShng Fa 2 3
## 2 AsbShng TA 4.63 5.26
## 3 AsphShn TA 5 5
## 4 BrkComm TA 4 3
## 5 BrkFace Gd 7.33 5.83
## 6 BrkFace TA 5.47 5.61
## 7 CBlock Fa 4 6
## 8 CemntBd Ex 8.8 5.53
## 9 CemntBd Gd 7.73 5.23
## 10 CemntBd TA 4.83 5.92
## # ℹ 27 more rows
Se tiene las siguientes clasificaciones para ExterQual: Ex (Excelente, el material es de alta gama), Fa (Justo, la calidad del material es bastante baja), Gd (Bueno, la calidad del material es buena) y TA (Típico/Promedio, el material tiene una condición funcional pero no excepcional). Haciendo un análisis rápido se puede ver que la fachada que presenta las mejores condiciones con respecto a calidad y condición es la “Wd Sdng”, se puede ver que existen fachadas que se ven perjudicadas a pesar de usar materiales de alta calidad, inidicando que estas fachadas es mejor abaratar sus costos y hacerlas con materiales que tengan una mejor duración ante la calidad.
Análisis Exploratorio por Grupos
Para evitar cualquier tipo de ambigüedades y malinterpretación de los datos, se van a omitir todas las variables cualitativas, ya que no encajan correctamente en el agrupamiento hecho por el clustering.
Con respecto a las variables cuantitativas, solo se va a hacer la omisión de GarageYrBlt, debido a que el año en que se construyó el garaje no aporta mucha información al agrupamiento de los datos.
De igual forma, los valores identificados como NA se
reescribieron como 0, debido a que este era el valor
que representaba ese tipo de datos en las columnas respectivas donde
aparecía.
Al final estas son las variables a analizar durante el agrupamiento: Id, MSSubClass, LotFrontage, LotArea, OverallQual, OverallCond, YearBuilt, YearRemodAdd, MasVnrArea, BsmtFinSF1, BsmtFinSF2, BsmtUnfSF, TotalBsmtSF, X1stFlrSF, X2ndFlrSF, LowQualFinSF, GrLivArea, BsmtFullBath, BsmtHalfBath, FullBath, HalfBath, BedroomAbvGr, KitchenAbvGr, TotRmsAbvGrd, Fireplaces, GarageCars, GarageArea, WoodDeckSF, OpenPorchSF, EnclosedPorch, X3SsnPorch, ScreenPorch, PoolArea, MiscVal, MoSold, YrSold, SalePrice.
Para determinar si existe una relación entre nuestras variables calculamos el estadístico de Hopkins.
## Estadistico de Hopkins: 1
Al obtener 1 como valor de Hopkins, esto demuestra que nuestros datos tiene una fuerte estructura de agrupamiento. Ahora se va a determinar la cantidad óptima de grupos para hacer el agrupamiento.
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
Viendo el gráfico de codo se refleja que el número óptimo de grupos es de 3. Para el agrupamiento de los datos se va a utilizar K-means. Utilizando K-means obtenemos los siguientes resultados del agrupamiento:
## Group.1 Id MSSubClass LotFrontage LotArea OverallQual OverallCond
## 1 1 738.4169 59.29901 53.94789 8731.475 5.254342 5.703474
## 2 2 734.6505 55.64486 58.11776 11867.650 6.844860 5.435514
## 3 3 658.2185 46.26050 80.29412 16536.193 8.470588 5.336134
## YearBuilt YearRemodAdd MasVnrArea BsmtFinSF1 BsmtFinSF2 BsmtUnfSF TotalBsmtSF
## 1 1955.872 1974.983 56.47395 358.5509 49.75558 469.9553 878.2618
## 2 1988.925 1995.744 120.70654 466.1738 46.29159 679.4579 1191.9234
## 3 1996.160 2002.899 339.95798 918.6471 25.99160 721.6555 1666.2941
## X1stFlrSF X2ndFlrSF LowQualFinSF GrLivArea BsmtFullBath BsmtHalfBath FullBath
## 1 1010.988 227.5112 6.667494 1245.166 0.3598015 0.06575682 1.260546
## 2 1270.095 469.0000 4.835514 1743.931 0.4523364 0.05046729 1.906542
## 3 1706.538 607.7311 4.806723 2319.076 0.7478992 0.03361345 2.092437
## HalfBath BedroomAbvGr KitchenAbvGr TotRmsAbvGrd Fireplaces GarageCars
## 1 0.2531017 2.767990 1.076923 5.901985 0.3920596 1.394541
## 2 0.5308411 2.975701 1.011215 7.013084 0.8093458 2.106542
## 3 0.5966387 3.042017 1.000000 8.462185 1.2268908 2.764706
## GarageArea WoodDeckSF OpenPorchSF EnclosedPorch X3SsnPorch ScreenPorch
## 1 375.6725 64.53474 28.63400 29.028536 1.514888 12.02978
## 2 554.3981 116.43738 64.57196 14.201869 5.854206 18.60000
## 3 766.0168 195.69748 88.22689 8.890756 5.252101 19.68067
## PoolArea MiscVal MoSold YrSold SalePrice
## 1 1.310174 53.73945 6.172457 2007.836 129374.1
## 2 4.517757 37.71963 6.476636 2007.789 215791.3
## 3 4.663866 0.00000 6.638655 2007.798 373286.7
Se puede ver que cada clusters representa lo siguiente: las propiedades de menor tamaño, calidad y precio (grupo 1); las propiedades de tamaño y calidad medios, con precios intermedios (grupo 2); y las propiedades de mayor tamaño, calidad y precio (grupo 3). Este agrupamiento indica un comportamiento esperable en el que el grupo 3 tiene las variables con los valores más altos, al ser las propiedades con mejor calidad y precio. Esto implica que la utilización de una mayor cantidad de recursos hace que aumente tanto el valor de la propiedad como de su calidad. Las variables que más terminan influyendo en esta separación por grupos temrinan siendo aquellas relacionadas con el tamaño y la calidad de la propiedad.
Ingeniería de Características
Como se pudo ver por el análisis exploratorio realizado con anterioridad salieron varios candidatos para predecir el precio de una casa, sin embargo, una de las variables que tuvo una fuerte correlación con el precio fue el tipo de fundación de la casa, ya que de forma muy consisntente las casas con una fundación PConc (Poured Concrete) tienen un precio más elevado comparado con las Slab o incluso las BrkTil (Brick and Tile).
Modelos
Primero vamos a realizar un modelo univariad que intenta predecir el precio de venta de la casa usando solamente la variable OveralQual ya que en nuestro análisis exploratorio descubrimos que tiene un alto coeficiente de correlación con el precio de venta:
##
## Call:
## lm(formula = SalePrice ~ GrLivArea, data = training_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -462999 -29800 -1124 21957 339832
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 18569.026 4480.755 4.144 3.61e-05 ***
## GrLivArea 107.130 2.794 38.348 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 56070 on 1458 degrees of freedom
## Multiple R-squared: 0.5021, Adjusted R-squared: 0.5018
## F-statistic: 1471 on 1 and 1458 DF, p-value: < 2.2e-16
## `geom_smooth()` using formula = 'y ~ x'
Como se puede ver por los datos el modelo realmente solo explica el 50.21% de la variabilidad en el precio, en este caso como solamente usa una variable eso se aplica a GrLivArea. Esto se confirma además con los residuos que son muy amplios, teniendo un 25% de errores en donde se subestimó el precio por $29,800 o menos y un máximo en donde se subestimó por $339,832!
Aunque el p-value es mucho menor a 0.05 sabemos que esto no es suficiente puesto que en promedio según el Error estándar residual nuestro modelo se equivoca por $56,070 mas o menos.
Regresión para variables numéricas
En este caso la regresión de las variables se va a realizar con las variables cuantitaticas; omitiendo todas la variables cualitativas, aunque tengan una representación numérica. De esta forma obtendremos una regresión lineal lo suficientemente precisa para predecir el precio de las casas.
##
## Call:
## lm(formula = SalePrice ~ ., data = num_vars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -535822 -17277 -2113 15927 309148
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.413e+05 1.534e+06 -0.483 0.628923
## LotFrontage 5.735e+01 3.067e+01 1.870 0.061683 .
## LotArea 3.007e-01 1.086e-01 2.768 0.005719 **
## YearBuilt 3.582e+02 5.743e+01 6.238 5.83e-10 ***
## YearRemodAdd 4.384e+02 6.494e+01 6.751 2.13e-11 ***
## MasVnrArea 3.463e+01 6.446e+00 5.372 9.09e-08 ***
## BsmtFinSF1 3.019e+01 5.021e+00 6.013 2.31e-09 ***
## BsmtFinSF2 1.800e+01 7.659e+00 2.350 0.018925 *
## BsmtUnfSF 2.219e+01 4.441e+00 4.996 6.56e-07 ***
## X1stFlrSF 5.437e+01 6.232e+00 8.724 < 2e-16 ***
## X2ndFlrSF 5.516e+01 5.144e+00 10.724 < 2e-16 ***
## LowQualFinSF 1.422e+01 2.140e+01 0.664 0.506544
## BsmtFullBath 6.725e+03 2.832e+03 2.375 0.017675 *
## BsmtHalfBath 1.095e+03 4.427e+03 0.247 0.804682
## FullBath 4.339e+03 3.055e+03 1.420 0.155738
## HalfBath -2.773e+03 2.896e+03 -0.958 0.338393
## BedroomAbvGr -1.193e+04 1.794e+03 -6.653 4.07e-11 ***
## KitchenAbvGr -4.277e+04 5.214e+03 -8.202 5.21e-16 ***
## TotRmsAbvGrd 6.876e+03 1.336e+03 5.147 3.02e-07 ***
## Fireplaces 7.811e+03 1.910e+03 4.090 4.55e-05 ***
## GarageYrBlt -1.202e+01 2.922e+00 -4.115 4.09e-05 ***
## GarageCars 1.831e+04 3.235e+03 5.661 1.82e-08 ***
## GarageArea 9.498e+00 1.062e+01 0.894 0.371334
## WoodDeckSF 2.713e+01 8.676e+00 3.128 0.001798 **
## OpenPorchSF 4.840e+00 1.650e+01 0.293 0.769327
## EnclosedPorch 2.539e+01 1.814e+01 1.400 0.161878
## X3SsnPorch 2.713e+01 3.408e+01 0.796 0.426124
## ScreenPorch 6.649e+01 1.868e+01 3.560 0.000382 ***
## PoolArea -4.579e+01 2.575e+01 -1.778 0.075560 .
## MiscVal 5.198e-01 2.017e+00 0.258 0.796673
## MoSold 3.622e+02 3.738e+02 0.969 0.332652
## YrSold -3.853e+02 7.629e+02 -0.505 0.613554
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 37790 on 1428 degrees of freedom
## Multiple R-squared: 0.7785, Adjusted R-squared: 0.7737
## F-statistic: 161.9 on 31 and 1428 DF, p-value: < 2.2e-16
En el resumen del modelo realizado se puede ver que la distribución de los residuos presenta un rango amplio (-535822 a 309148), esto indica que el modelo puede tener dificultades para predecir algunos valores extremos. Estos valores de máximo y mínimo implica la presencia de datos atípicos, que es lo que hace que el modelo no prediga a la perfección datos extremos.
Evaluando las variables significativas podemos ver las siguientes: YearBuilt, YearRemodAdd, MasVnrArea, BsmtFinSF1, BsmtUnfSF, X1stFlrSF, X2ndFlrSF, BedroomAbvGr, KitchenAbvGr, TotRmsAbvGrd, Fireplaces, GarageYrsBlt, GarageCars, WoodDeckSF, ScreenPorch.
Viendo a profuncdidad las métricas podemos encontrar lo siguiente. El R-cuadrado es 0.7785, significando que el modelo explica aproximadamente el 77.85% de la variabilidad en el precio de venta. Viendo que el R-cuadrado ajustado es ligeramente menor al R-cuadrado, demuestra que hay variables incluidas en el modelo que no estan contribuyendo a la predicción.
Para ver de forma gráfica el modelo de regresión, se hace el gráfico de dispersión entre cada una de las variables predictoras y el precio de venta. A continuación se muestra la relación de las variables significativas encontradas:
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Multicolinealidad entre variables
## corrplot 0.95 loaded
Analizando el gráifco de correlación se puede busca aquellas variables en donde se encuentre una fuerte intensidad de color azul. Bajo este criterio se tiene multicolinealidad entre las sigueinte variables.
YearBuilt y YearRemoveAdd: Existe correlación entre estas variables debido a que mientras más antigua sea la casa, más probable es que se hayan hecho remodelaciones en esta.
YearBuilt y GarageYrBlt: Claramente esta correlación indica que al momento de construir la casa se contruyo simultaneamente el garaje.
TotRmsAbvGrd y GrLivArea: La correlación positiva existe entre el núemro total de habitaciones sobre el nivel del suelo y el área habitable sobre el nivel del suelo demuestra que las casas más grandes tienden a tener más habitaciones.
GarageCars y GarageArea: Para un garaje más ampio, se puede almacenar más carros.
Identificación de variables de mayor impacto
## LotFrontage LotArea YearBuilt YearRemodAdd MasVnrArea
## LotFrontage 1.000000000 0.100738810 0.036853429 0.078685515 0.105009833
## LotArea 0.100738810 1.000000000 0.014227652 0.013788427 0.103320506
## YearBuilt 0.036853429 0.014227652 1.000000000 0.592854976 0.311600107
## YearRemodAdd 0.078685515 0.013788427 0.592854976 1.000000000 0.176529181
## MasVnrArea 0.105009833 0.103320506 0.311600107 0.176529181 1.000000000
## BsmtFinSF1 0.076669997 0.214103131 0.249503197 0.128450547 0.261256055
## BsmtFinSF2 -0.009312309 0.111169745 -0.049106831 -0.067758514 -0.071329628
## BsmtUnfSF 0.160829277 -0.002618360 0.149040392 0.181133087 0.113862163
## X1stFlrSF 0.245180931 0.299474579 0.281985859 0.240379268 0.339850414
## X2ndFlrSF 0.042549244 0.050985948 0.010307660 0.140023779 0.173800000
## LowQualFinSF 0.049981430 0.004778970 -0.183784344 -0.062419100 -0.068627980
## BsmtFullBath 0.010514333 0.158154531 0.187598550 0.119469879 0.083010048
## BsmtHalfBath -0.027855658 0.048045571 -0.038161806 -0.012337032 0.027402662
## FullBath 0.120547870 0.126030627 0.468270787 0.439046484 0.272998856
## HalfBath -0.012952103 0.014259469 0.242655910 0.183330612 0.199107519
## BedroomAbvGr 0.144493646 0.119689908 -0.070651217 -0.040580928 0.102774516
## KitchenAbvGr 0.034424658 -0.017783871 -0.174800246 -0.149597521 -0.038450112
## TotRmsAbvGrd 0.221396241 0.190014778 0.095589128 0.191739816 0.279567888
## Fireplaces 0.044017642 0.271364010 0.147716399 0.112581318 0.247015277
## GarageYrBlt 0.019316523 0.072598768 0.272029321 0.146357224 0.132696387
## GarageCars 0.165228607 0.154870740 0.537850092 0.420622155 0.361944566
## GarageArea 0.201473353 0.180402755 0.478953820 0.371599809 0.370884153
## WoodDeckSF -0.016779759 0.171697687 0.224880142 0.205725920 0.159990530
## OpenPorchSF 0.069604952 0.084773809 0.188685840 0.226297633 0.122528332
## EnclosedPorch 0.027366105 -0.018339734 -0.387267783 -0.193919147 -0.109906797
## X3SsnPorch 0.023498724 0.020422830 0.031354513 0.045285810 0.019143784
## ScreenPorch 0.022968732 0.043160378 -0.050364435 -0.038740011 0.062247711
## PoolArea 0.114106359 0.077672392 0.004949728 0.005829372 0.011928394
## MiscVal -0.059605730 0.038067692 -0.034383139 -0.010286249 -0.029512249
## MoSold 0.018941943 0.001204988 0.012398471 0.021490002 -0.006723204
## YrSold -0.012093960 -0.014261407 -0.013617680 0.035743247 -0.008316623
## SalePrice 0.209623945 0.263843354 0.522897333 0.507100967 0.472614499
## BsmtFinSF1 BsmtFinSF2 BsmtUnfSF X1stFlrSF X2ndFlrSF
## LotFrontage 0.076669997 -0.009312309 0.160829277 0.245180931 0.042549244
## LotArea 0.214103131 0.111169745 -0.002618360 0.299474579 0.050985948
## YearBuilt 0.249503197 -0.049106831 0.149040392 0.281985859 0.010307660
## YearRemodAdd 0.128450547 -0.067758514 0.181133087 0.240379268 0.140023779
## MasVnrArea 0.261256055 -0.071329628 0.113862163 0.339850414 0.173800000
## BsmtFinSF1 1.000000000 -0.050117400 -0.495251469 0.445862656 -0.137078986
## BsmtFinSF2 -0.050117400 1.000000000 -0.209294492 0.097117448 -0.099260316
## BsmtUnfSF -0.495251469 -0.209294492 1.000000000 0.317987438 0.004469092
## X1stFlrSF 0.445862656 0.097117448 0.317987438 1.000000000 -0.202646181
## X2ndFlrSF -0.137078986 -0.099260316 0.004469092 -0.202646181 1.000000000
## LowQualFinSF -0.064502597 0.014806998 0.028166688 -0.014240673 0.063352950
## BsmtFullBath 0.649211754 0.158678061 -0.422900477 0.244671104 -0.169493952
## BsmtHalfBath 0.067418478 0.070948134 -0.095804288 0.001955654 -0.023854784
## FullBath 0.058543137 -0.076443862 0.288886055 0.380637495 0.421377983
## HalfBath 0.004262424 -0.032147837 -0.041117530 -0.119915909 0.609707300
## BedroomAbvGr -0.107354677 -0.015728114 0.166643317 0.127400749 0.502900613
## KitchenAbvGr -0.081006851 -0.040751236 0.030085868 0.068100588 0.059305753
## TotRmsAbvGrd 0.044315624 -0.035226548 0.250647061 0.409515979 0.616422635
## Fireplaces 0.260010920 0.046920709 0.051574882 0.410531085 0.194560892
## GarageYrBlt 0.115842631 0.035069883 0.042719961 0.166641644 0.064401834
## GarageCars 0.224053522 -0.038263513 0.214175190 0.439316808 0.183925583
## GarageArea 0.296970385 -0.018226592 0.183302698 0.489781654 0.138346959
## WoodDeckSF 0.204306145 0.067898326 -0.005316424 0.235458623 0.092165418
## OpenPorchSF 0.111760613 0.003092562 0.129005415 0.211671225 0.208026063
## EnclosedPorch -0.102303306 0.036543339 -0.002537855 -0.065291701 0.061988691
## X3SsnPorch 0.026450506 -0.029993398 0.020764006 0.056104374 -0.024357648
## ScreenPorch 0.062020623 0.088871251 -0.012579273 0.088758073 0.040606448
## PoolArea 0.140491286 0.041709055 -0.035092241 0.131524976 0.081486878
## MiscVal 0.003571473 0.004939781 -0.023836645 -0.021095719 0.016196875
## MoSold -0.015726948 -0.015210738 0.034888443 0.031371560 0.035164427
## YrSold 0.014358922 0.031705637 -0.041258195 -0.013603771 -0.028699914
## SalePrice 0.386419806 -0.011378121 0.214479106 0.605852185 0.319333803
## LowQualFinSF BsmtFullBath BsmtHalfBath FullBath
## LotFrontage 0.0499814302 0.0105143334 -0.027855658 0.1205478702
## LotArea 0.0047789699 0.1581545311 0.048045571 0.1260306265
## YearBuilt -0.1837843444 0.1875985500 -0.038161806 0.4682707872
## YearRemodAdd -0.0624191001 0.1194698791 -0.012337032 0.4390464839
## MasVnrArea -0.0686279799 0.0830100478 0.027402662 0.2729988557
## BsmtFinSF1 -0.0645025969 0.6492117536 0.067418478 0.0585431369
## BsmtFinSF2 0.0148069979 0.1586780608 0.070948134 -0.0764438620
## BsmtUnfSF 0.0281666881 -0.4229004774 -0.095804288 0.2888860555
## X1stFlrSF -0.0142406727 0.2446711042 0.001955654 0.3806374950
## X2ndFlrSF 0.0633529501 -0.1694939517 -0.023854784 0.4213779829
## LowQualFinSF 1.0000000000 -0.0471434219 -0.005841505 -0.0007095096
## BsmtFullBath -0.0471434219 1.0000000000 -0.147870961 -0.0645120486
## BsmtHalfBath -0.0058415048 -0.1478709605 1.000000000 -0.0545358120
## FullBath -0.0007095096 -0.0645120486 -0.054535812 1.0000000000
## HalfBath -0.0270800493 -0.0309049591 -0.012339900 0.1363805887
## BedroomAbvGr 0.1056065685 -0.1506728092 0.046518848 0.3632519830
## KitchenAbvGr 0.0075217443 -0.0415025464 -0.037944350 0.1331152142
## TotRmsAbvGrd 0.1311847760 -0.0532752361 -0.023836341 0.5547842535
## Fireplaces -0.0212721434 0.1379277084 0.028975587 0.2436705031
## GarageYrBlt -0.1464672575 0.0492696521 0.016811230 0.1374638870
## GarageCars -0.0944795202 0.1318812244 -0.020891059 0.4696720433
## GarageArea -0.0676014132 0.1791894804 -0.024535580 0.4056562085
## WoodDeckSF -0.0254436480 0.1753151901 0.040161223 0.1877032138
## OpenPorchSF 0.0182510391 0.0673414614 -0.025323758 0.2599774255
## EnclosedPorch 0.0610812378 -0.0499106491 -0.008555334 -0.1150929635
## X3SsnPorch -0.0042956104 -0.0001060915 0.035113631 0.0353530166
## ScreenPorch 0.0267994130 0.0231477258 0.032121407 -0.0081060933
## PoolArea 0.0621573723 0.0676155562 0.020024630 0.0496038256
## MiscVal -0.0037928708 -0.0230470249 -0.007366525 -0.0142898450
## MoSold -0.0221739606 -0.0253608943 0.032872705 0.0558721290
## YrSold -0.0289208798 0.0670491377 -0.046523882 -0.0196688407
## SalePrice -0.0256061300 0.2271222331 -0.016844154 0.5606637627
## HalfBath BedroomAbvGr KitchenAbvGr TotRmsAbvGrd Fireplaces
## LotFrontage -0.012952103 0.144493646 0.034424658 0.221396241 0.044017642
## LotArea 0.014259469 0.119689908 -0.017783871 0.190014778 0.271364010
## YearBuilt 0.242655910 -0.070651217 -0.174800246 0.095589128 0.147716399
## YearRemodAdd 0.183330612 -0.040580928 -0.149597521 0.191739816 0.112581318
## MasVnrArea 0.199107519 0.102774516 -0.038450112 0.279567888 0.247015277
## BsmtFinSF1 0.004262424 -0.107354677 -0.081006851 0.044315624 0.260010920
## BsmtFinSF2 -0.032147837 -0.015728114 -0.040751236 -0.035226548 0.046920709
## BsmtUnfSF -0.041117530 0.166643317 0.030085868 0.250647061 0.051574882
## X1stFlrSF -0.119915909 0.127400749 0.068100588 0.409515979 0.410531085
## X2ndFlrSF 0.609707300 0.502900613 0.059305753 0.616422635 0.194560892
## LowQualFinSF -0.027080049 0.105606569 0.007521744 0.131184776 -0.021272143
## BsmtFullBath -0.030904959 -0.150672809 -0.041502546 -0.053275236 0.137927708
## BsmtHalfBath -0.012339900 0.046518848 -0.037944350 -0.023836341 0.028975587
## FullBath 0.136380589 0.363251983 0.133115214 0.554784254 0.243670503
## HalfBath 1.000000000 0.226651484 -0.068262549 0.343414858 0.203648508
## BedroomAbvGr 0.226651484 1.000000000 0.198596758 0.676619936 0.107569681
## KitchenAbvGr -0.068262549 0.198596758 1.000000000 0.256045409 -0.123936235
## TotRmsAbvGrd 0.343414858 0.676619936 0.256045409 1.000000000 0.326114480
## Fireplaces 0.203648508 0.107569681 -0.123936235 0.326114480 1.000000000
## GarageYrBlt 0.117166074 -0.009849549 -0.157991391 0.095607272 0.186263762
## GarageCars 0.219178152 0.086106438 -0.050633892 0.362288571 0.300788766
## GarageArea 0.163549364 0.065252530 -0.064433047 0.337822121 0.269141238
## WoodDeckSF 0.108080303 0.046853773 -0.090130273 0.165983884 0.200018796
## OpenPorchSF 0.199740148 0.093809572 -0.070090610 0.234191588 0.169405327
## EnclosedPorch -0.095316526 0.041570435 0.037312385 0.004151299 -0.024821869
## X3SsnPorch -0.004972488 -0.024477796 -0.024600359 -0.006683241 0.011257239
## ScreenPorch 0.072425845 0.044299691 -0.051613366 0.059382600 0.184530270
## PoolArea 0.022381498 0.070702584 -0.014525116 0.083757350 0.095073522
## MiscVal 0.001290145 0.007766972 0.062340724 0.024762884 0.001408605
## MoSold -0.009049888 0.046543860 0.026588907 0.036907077 0.046357102
## YrSold -0.010268669 -0.036013893 0.031687207 -0.034516354 -0.024095565
## SalePrice 0.284107676 0.168213154 -0.135907371 0.533723156 0.466928837
## GarageYrBlt GarageCars GarageArea WoodDeckSF OpenPorchSF
## LotFrontage 0.019316523 0.16522861 0.20147335 -0.016779759 0.069604952
## LotArea 0.072598768 0.15487074 0.18040276 0.171697687 0.084773809
## YearBuilt 0.272029321 0.53785009 0.47895382 0.224880142 0.188685840
## YearRemodAdd 0.146357224 0.42062215 0.37159981 0.205725920 0.226297633
## MasVnrArea 0.132696387 0.36194457 0.37088415 0.159990530 0.122528332
## BsmtFinSF1 0.115842631 0.22405352 0.29697039 0.204306145 0.111760613
## BsmtFinSF2 0.035069883 -0.03826351 -0.01822659 0.067898326 0.003092562
## BsmtUnfSF 0.042719961 0.21417519 0.18330270 -0.005316424 0.129005415
## X1stFlrSF 0.166641644 0.43931681 0.48978165 0.235458623 0.211671225
## X2ndFlrSF 0.064401834 0.18392558 0.13834696 0.092165418 0.208026063
## LowQualFinSF -0.146467258 -0.09447952 -0.06760141 -0.025443648 0.018251039
## BsmtFullBath 0.049269652 0.13188122 0.17918948 0.175315190 0.067341461
## BsmtHalfBath 0.016811230 -0.02089106 -0.02453558 0.040161223 -0.025323758
## FullBath 0.137463887 0.46967204 0.40565621 0.187703214 0.259977425
## HalfBath 0.117166074 0.21917815 0.16354936 0.108080303 0.199740148
## BedroomAbvGr -0.009849549 0.08610644 0.06525253 0.046853773 0.093809572
## KitchenAbvGr -0.157991391 -0.05063389 -0.06443305 -0.090130273 -0.070090610
## TotRmsAbvGrd 0.095607272 0.36228857 0.33782212 0.165983884 0.234191588
## Fireplaces 0.186263762 0.30078877 0.26914124 0.200018796 0.169405327
## GarageYrBlt 1.000000000 0.59800465 0.56078287 0.117304806 0.049876937
## GarageCars 0.598004645 1.00000000 0.88247541 0.226342138 0.213569446
## GarageArea 0.560782870 0.88247541 1.00000000 0.224666307 0.241434672
## WoodDeckSF 0.117304806 0.22634214 0.22466631 1.000000000 0.058660609
## OpenPorchSF 0.049876937 0.21356945 0.24143467 0.058660609 1.000000000
## EnclosedPorch -0.076821586 -0.15143416 -0.12177672 -0.125988888 -0.093079318
## X3SsnPorch 0.029401147 0.03576529 0.03508670 -0.032770634 -0.005842499
## ScreenPorch 0.061415936 0.05049379 0.05141176 -0.074181351 0.074303944
## PoolArea 0.015858024 0.02093353 0.06104727 0.073378207 0.060762111
## MiscVal -0.006669285 -0.04308013 -0.02739991 -0.009551228 -0.018583739
## MoSold 0.019150855 0.04052173 0.02797380 0.021011044 0.071254885
## YrSold -0.011133813 -0.03911690 -0.02737794 0.022270451 -0.057619360
## SalePrice 0.261366435 0.64040920 0.62343144 0.324413445 0.315856227
## EnclosedPorch X3SsnPorch ScreenPorch PoolArea
## LotFrontage 0.027366105 0.0234987244 0.022968732 0.114106359
## LotArea -0.018339734 0.0204228296 0.043160378 0.077672392
## YearBuilt -0.387267783 0.0313545131 -0.050364435 0.004949728
## YearRemodAdd -0.193919147 0.0452858098 -0.038740011 0.005829372
## MasVnrArea -0.109906797 0.0191437843 0.062247711 0.011928394
## BsmtFinSF1 -0.102303306 0.0264505062 0.062020623 0.140491286
## BsmtFinSF2 0.036543339 -0.0299933980 0.088871251 0.041709055
## BsmtUnfSF -0.002537855 0.0207640057 -0.012579273 -0.035092241
## X1stFlrSF -0.065291701 0.0561043745 0.088758073 0.131524976
## X2ndFlrSF 0.061988691 -0.0243576484 0.040606448 0.081486878
## LowQualFinSF 0.061081238 -0.0042956104 0.026799413 0.062157372
## BsmtFullBath -0.049910649 -0.0001060915 0.023147726 0.067615556
## BsmtHalfBath -0.008555334 0.0351136309 0.032121407 0.020024630
## FullBath -0.115092963 0.0353530166 -0.008106093 0.049603826
## HalfBath -0.095316526 -0.0049724884 0.072425845 0.022381498
## BedroomAbvGr 0.041570435 -0.0244777964 0.044299691 0.070702584
## KitchenAbvGr 0.037312385 -0.0246003587 -0.051613366 -0.014525116
## TotRmsAbvGrd 0.004151299 -0.0066832410 0.059382600 0.083757350
## Fireplaces -0.024821869 0.0112572390 0.184530270 0.095073522
## GarageYrBlt -0.076821586 0.0294011473 0.061415936 0.015858024
## GarageCars -0.151434160 0.0357652851 0.050493792 0.020933531
## GarageArea -0.121776720 0.0350867002 0.051411762 0.061047272
## WoodDeckSF -0.125988888 -0.0327706336 -0.074181351 0.073378207
## OpenPorchSF -0.093079318 -0.0058424993 0.074303944 0.060762111
## EnclosedPorch 1.000000000 -0.0373052828 -0.082864245 0.054202562
## X3SsnPorch -0.037305283 1.0000000000 -0.031435847 -0.007991549
## ScreenPorch -0.082864245 -0.0314358470 1.000000000 0.051307395
## PoolArea 0.054202562 -0.0079915489 0.051307395 1.000000000
## MiscVal 0.018360600 0.0003539653 0.031945761 0.029668651
## MoSold -0.028887266 0.0294737952 0.023216992 -0.033736640
## YrSold -0.009915937 0.0186449254 0.010694106 -0.059688932
## SalePrice -0.128577958 0.0445836653 0.111446571 0.092403549
## MiscVal MoSold YrSold SalePrice
## LotFrontage -0.0596057301 0.018941943 -0.012093960 0.20962394
## LotArea 0.0380676920 0.001204988 -0.014261407 0.26384335
## YearBuilt -0.0343831387 0.012398471 -0.013617680 0.52289733
## YearRemodAdd -0.0102862488 0.021490002 0.035743247 0.50710097
## MasVnrArea -0.0295122487 -0.006723204 -0.008316623 0.47261450
## BsmtFinSF1 0.0035714735 -0.015726948 0.014358922 0.38641981
## BsmtFinSF2 0.0049397812 -0.015210738 0.031705637 -0.01137812
## BsmtUnfSF -0.0238366451 0.034888443 -0.041258195 0.21447911
## X1stFlrSF -0.0210957195 0.031371560 -0.013603771 0.60585218
## X2ndFlrSF 0.0161968746 0.035164427 -0.028699914 0.31933380
## LowQualFinSF -0.0037928708 -0.022173961 -0.028920880 -0.02560613
## BsmtFullBath -0.0230470249 -0.025360894 0.067049138 0.22712223
## BsmtHalfBath -0.0073665245 0.032872705 -0.046523882 -0.01684415
## FullBath -0.0142898450 0.055872129 -0.019668841 0.56066376
## HalfBath 0.0012901448 -0.009049888 -0.010268669 0.28410768
## BedroomAbvGr 0.0077669720 0.046543860 -0.036013893 0.16821315
## KitchenAbvGr 0.0623407240 0.026588907 0.031687207 -0.13590737
## TotRmsAbvGrd 0.0247628842 0.036907077 -0.034516354 0.53372316
## Fireplaces 0.0014086054 0.046357102 -0.024095565 0.46692884
## GarageYrBlt -0.0066692852 0.019150855 -0.011133813 0.26136644
## GarageCars -0.0430801281 0.040521730 -0.039116904 0.64040920
## GarageArea -0.0273999144 0.027973800 -0.027377940 0.62343144
## WoodDeckSF -0.0095512282 0.021011044 0.022270451 0.32441344
## OpenPorchSF -0.0185837390 0.071254885 -0.057619360 0.31585623
## EnclosedPorch 0.0183606001 -0.028887266 -0.009915937 -0.12857796
## X3SsnPorch 0.0003539653 0.029473795 0.018644925 0.04458367
## ScreenPorch 0.0319457608 0.023216992 0.010694106 0.11144657
## PoolArea 0.0296686509 -0.033736640 -0.059688932 0.09240355
## MiscVal 1.0000000000 -0.006494550 0.004906262 -0.02118958
## MoSold -0.0064945502 1.000000000 -0.145721413 0.04643225
## YrSold 0.0049062625 -0.145721413 1.000000000 -0.02892259
## SalePrice -0.0211895796 0.046432245 -0.028922585 1.00000000
- YearBuilt (0.52): El año de construcción de la casa tiene una correlación positiva moderada. Esto sugiere que las casas más nuevas tienden a tener precios más altos.
- YearRemodAdd (0.51): El año de la última remodelación también tiene una correlación positiva moderada. Esto indica que las casas remodeladas recientemente tienden a tener precios más altos.
- MasVnrArea (0.47): El área de revestimiento de mampostería tiene una correlación positiva moderada. Esto sugiere que las casas con más revestimiento de mampostería tienden a tener precios más altos.
- BsmtFinSF1 (0.39): El área de pies cuadrados terminados del sótano de tipo 1 tiene una correlación positiva moderada. Esto indica que los sótanos terminados contribuyen al precio de la casa.
- X1stFlrSF (0.61): El área de pies cuadrados del primer piso tiene una correlación positiva fuerte. Esto es lógico, ya que un área de primer piso más grande generalmente significa una casa más grande y, por lo tanto, más cara.
- FullBath (0.56): El número de baños completos tiene una correlación positiva moderada. Más baños completos generalmente aumentan el precio de la casa.
- TotRmsAbvGrd (0.53): El número total de habitaciones sobre el nivel del suelo tiene una correlación positiva moderada. Más habitaciones generalmente significan una casa más grande y, por lo tanto, más cara.
- Fireplaces (0.47): El número de chimeneas tiene una correlación positiva moderada. Las chimeneas son una característica deseable que puede aumentar el precio de la casa.
- GarageCars (0.64): El tamaño del garaje en capacidad de automóviles tiene una correlación positiva fuerte. Un garaje más grande generalmente aumenta el precio de la casa.
- GarageArea (0.62): El tamaño del garaje en área tiene una correlación positiva fuerte. Similar a GarageCars, un garaje más grande aumenta el precio.
- WoodDeckSF (0.32): El área de la terraza de madera tiene una correlación positiva moderada. Las terrazas de madera son una característica deseable que puede aumentar el precio.
- OpenPorchSF (0.32): El área del porche abierto tiene una correlación positiva moderada. Similar a la terraza de madera, un porche abierto es una característica deseable.
Habiendo analizado la relación entre variables anteriormente se van a omitir las variables GarageCars y YearRemodAdd, debido a que estan altamente correlacionadas con GarageArea y YearBuilt respectivamente.
Identificar sobreajuste
##
## Call:
## lm(formula = SalePrice ~ ., data = num_vars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -535822 -17277 -2113 15927 309148
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.413e+05 1.534e+06 -0.483 0.628923
## LotFrontage 5.735e+01 3.067e+01 1.870 0.061683 .
## LotArea 3.007e-01 1.086e-01 2.768 0.005719 **
## YearBuilt 3.582e+02 5.743e+01 6.238 5.83e-10 ***
## YearRemodAdd 4.384e+02 6.494e+01 6.751 2.13e-11 ***
## MasVnrArea 3.463e+01 6.446e+00 5.372 9.09e-08 ***
## BsmtFinSF1 3.019e+01 5.021e+00 6.013 2.31e-09 ***
## BsmtFinSF2 1.800e+01 7.659e+00 2.350 0.018925 *
## BsmtUnfSF 2.219e+01 4.441e+00 4.996 6.56e-07 ***
## X1stFlrSF 5.437e+01 6.232e+00 8.724 < 2e-16 ***
## X2ndFlrSF 5.516e+01 5.144e+00 10.724 < 2e-16 ***
## LowQualFinSF 1.422e+01 2.140e+01 0.664 0.506544
## BsmtFullBath 6.725e+03 2.832e+03 2.375 0.017675 *
## BsmtHalfBath 1.095e+03 4.427e+03 0.247 0.804682
## FullBath 4.339e+03 3.055e+03 1.420 0.155738
## HalfBath -2.773e+03 2.896e+03 -0.958 0.338393
## BedroomAbvGr -1.193e+04 1.794e+03 -6.653 4.07e-11 ***
## KitchenAbvGr -4.277e+04 5.214e+03 -8.202 5.21e-16 ***
## TotRmsAbvGrd 6.876e+03 1.336e+03 5.147 3.02e-07 ***
## Fireplaces 7.811e+03 1.910e+03 4.090 4.55e-05 ***
## GarageYrBlt -1.202e+01 2.922e+00 -4.115 4.09e-05 ***
## GarageCars 1.831e+04 3.235e+03 5.661 1.82e-08 ***
## GarageArea 9.498e+00 1.062e+01 0.894 0.371334
## WoodDeckSF 2.713e+01 8.676e+00 3.128 0.001798 **
## OpenPorchSF 4.840e+00 1.650e+01 0.293 0.769327
## EnclosedPorch 2.539e+01 1.814e+01 1.400 0.161878
## X3SsnPorch 2.713e+01 3.408e+01 0.796 0.426124
## ScreenPorch 6.649e+01 1.868e+01 3.560 0.000382 ***
## PoolArea -4.579e+01 2.575e+01 -1.778 0.075560 .
## MiscVal 5.198e-01 2.017e+00 0.258 0.796673
## MoSold 3.622e+02 3.738e+02 0.969 0.332652
## YrSold -3.853e+02 7.629e+02 -0.505 0.613554
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 37790 on 1428 degrees of freedom
## Multiple R-squared: 0.7785, Adjusted R-squared: 0.7737
## F-statistic: 161.9 on 31 and 1428 DF, p-value: < 2.2e-16
Para identificar si el modelo esta sobreajustado, se puede demostrar comparando los valores de R^2 y R^2 ajustado. En este caso se que ve que estos valores no presentan una diferencia significativa entre sí, indicanco que el modelo no se encuentra sobre ajustado.
Nuevo modelo
Debido a que se encontró multicolianidad entre las variables, se va a reajustar el modelo usando las variables que se encontraron como significativas y omitiendo aquellas que presentaron multicolianidad.
##
## Call:
## lm(formula = SalePrice ~ ., data = num_vars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -479296 -21755 -2134 17636 373149
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.094e+06 9.657e+04 -11.330 < 2e-16 ***
## YearBuilt 5.481e+02 4.961e+01 11.049 < 2e-16 ***
## MasVnrArea 5.001e+01 7.184e+00 6.961 5.10e-12 ***
## BsmtFinSF1 1.864e+01 2.971e+00 6.272 4.69e-10 ***
## X1stFlrSF 3.027e+01 4.008e+00 7.552 7.53e-14 ***
## FullBath 1.510e+04 2.939e+03 5.137 3.18e-07 ***
## TotRmsAbvGrd 1.075e+04 9.492e+02 11.324 < 2e-16 ***
## Fireplaces 1.801e+04 2.016e+03 8.933 < 2e-16 ***
## GarageArea 7.042e+01 6.977e+00 10.093 < 2e-16 ***
## WoodDeckSF 4.498e+01 9.670e+00 4.651 3.60e-06 ***
## OpenPorchSF 7.921e+01 1.828e+01 4.334 1.57e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 43690 on 1449 degrees of freedom
## Multiple R-squared: 0.6997, Adjusted R-squared: 0.6976
## F-statistic: 337.6 on 10 and 1449 DF, p-value: < 2.2e-16
Los residuos del modelo muestran una alta dispersión, con errores que varían desde -479296 hasta 373149, lo que indica que el modelo no es igualmente preciso para todas las predicciones. Aunque la mediana de los residuos está cerca de cero (-2134), lo que sugiere poco sesgo general, la amplia dispersión y la presencia de valores atípicos (outliers) indican que el modelo tiene margen de mejora.
El gráfico muestra que los errores del modelo se distribuyen bastante bien alrededor de cero, lo que sugiere que el modelo generalmente hace predicciones equilibradas. Sin embargo, los errores tienden a dispersarse más a medida que las predicciones del modelo aumentan, lo que indica que el modelo podría ser menos preciso para las predicciones más altas. Además, hay algunos errores muy grandes, tanto positivos como negativos, lo que sugiere que el modelo tiene dificultades para predecir con precisión algunos valores extremos.
Comparativa de los modelos
Ahora vamos a utilizar ambos modelos con los datos de prueba y comparar las respuestas de ambos:
##
## Call:
## lm(formula = SalePrice ~ GrLivArea, data = training_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -462999 -29800 -1124 21957 339832
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 18569.026 4480.755 4.144 3.61e-05 ***
## GrLivArea 107.130 2.794 38.348 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 56070 on 1458 degrees of freedom
## Multiple R-squared: 0.5021, Adjusted R-squared: 0.5018
## F-statistic: 1471 on 1 and 1458 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SalePrice ~ ., data = num_vars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -479296 -21755 -2134 17636 373149
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.094e+06 9.657e+04 -11.330 < 2e-16 ***
## YearBuilt 5.481e+02 4.961e+01 11.049 < 2e-16 ***
## MasVnrArea 5.001e+01 7.184e+00 6.961 5.10e-12 ***
## BsmtFinSF1 1.864e+01 2.971e+00 6.272 4.69e-10 ***
## X1stFlrSF 3.027e+01 4.008e+00 7.552 7.53e-14 ***
## FullBath 1.510e+04 2.939e+03 5.137 3.18e-07 ***
## TotRmsAbvGrd 1.075e+04 9.492e+02 11.324 < 2e-16 ***
## Fireplaces 1.801e+04 2.016e+03 8.933 < 2e-16 ***
## GarageArea 7.042e+01 6.977e+00 10.093 < 2e-16 ***
## WoodDeckSF 4.498e+01 9.670e+00 4.651 3.60e-06 ***
## OpenPorchSF 7.921e+01 1.828e+01 4.334 1.57e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 43690 on 1449 degrees of freedom
## Multiple R-squared: 0.6997, Adjusted R-squared: 0.6976
## F-statistic: 337.6 on 10 and 1449 DF, p-value: < 2.2e-16
## Analysis of Variance Table
##
## Model 1: SalePrice ~ GrLivArea
## Model 2: SalePrice ~ YearBuilt + MasVnrArea + BsmtFinSF1 + X1stFlrSF +
## FullBath + TotRmsAbvGrd + Fireplaces + GarageArea + WoodDeckSF +
## OpenPorchSF
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 1458 4.5842e+12
## 2 1449 2.7654e+12 9 1.8188e+12 105.89 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Como podemos ver por el resumen de ambos modelos, el modelo que utiliza varias variables explica un 69% de la variabilidad de los datos mientras que el de una sola variable apenas el 50% (casi igual que tirar una moneda). Realizando la prueba de ANOVA ambos modelos tienen el mismo valor p, lo que nos dice que aunque explica más de la variabilidad de las variables realmente no es un modelo que tenga más significancia.
Conclusiones
Las siguientes gráficas nos muestran las distribuciones de la variable SalePrice predichas por ambos modelos:
Como se puede ver por los histogramas ambas variables predichas siguen una distribución normal.
En conclusión, ambos modelos son malos para predecir el precio de las casas (alcanzando a lo mucho un 69% de variabilidad explicada), lo que nos dice que no siempre solo con tener más variables tendremos un modelo que prediga mejor los datos sino que es importante considerar también la significancia que tienen estos con la variable objetivo y encontrar datos que realmente se correlaciones de forma fuerte con la variable objetivo.
Con respecto a este estudio nuestras recomendaciones es buscar nuevas fuentes de información si se desea tener un modelo con mayor accuracy de predicción.
Modelado de Bayes
Debido al modelado de Bayes tenemos que discretizar la variable objetivo, en nuestro caso es SalePrice. La vamos a dividir en 4 categorìas: LOW, SEMI, MEDIUM, HIGH
Primero vamos a dividir el dataset the entrenamiento en 2 grupos, uno de entrenamiento con el 70% de los datos y otro de validación con el 30% de los datos.
## Warning: package 'e1071' was built under R version 4.4.3
## Warning: package 'caret' was built under R version 4.4.3
## Loading required package: lattice
## Warning: package 'glmnet' was built under R version 4.4.3
## Loading required package: Matrix
## Loaded glmnet 4.1-8
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Media Cara
## Barata 141 64 10
## Media 3 51 22
## Cara 0 29 117
##
## Overall Statistics
##
## Accuracy : 0.7071
## 95% CI : (0.662, 0.7494)
## No Information Rate : 0.341
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.5606
##
## Mcnemar's Test P-Value : 2.398e-14
##
## Statistics by Class:
##
## Class: Barata Class: Media Class: Cara
## Sensitivity 0.9792 0.3542 0.7852
## Specificity 0.7474 0.9147 0.8993
## Pos Pred Value 0.6558 0.6711 0.8014
## Neg Pred Value 0.9865 0.7424 0.8900
## Prevalence 0.3295 0.3295 0.3410
## Detection Rate 0.3227 0.1167 0.2677
## Detection Prevalence 0.4920 0.1739 0.3341
## Balanced Accuracy 0.8633 0.6344 0.8423
Para predecir la variable de SalePrice el modelo tuvo un Accuracy del 70%, lo que significa que sí ha encontrado patrones que implican un valor de venta mayor/menor. Comparando este modelo con los otros realizados con anterioridad el que mejor lo ha realizado hasta ahora es el de naïve Bayes aunque por muy poco, puesto que apenas superó por 1% al modelo de árboles de regresión.
Como se puede ver por la matriz de confusión la clase en la que más errores tuvo fue la clase barata, puesto que de todos los valores clasificados en “Barato” solamente el 65% fueron clasificados de forma correcta. La segunda categoría con más errores fue la media con el 67% clasificados de forma correcta y finalmente la Cara con 80%.
Es posible que esto se deba a los puntos atípicos del dataset se parte del precio de las casas, por lo que si quitamos las 2 casas con precio mayor tenemos:
## Warning in predict.naiveBayes(nb_model, test_data): Type mismatch between
## training and new data for variable 'Id'. Did you use factors with numeric
## labels for training, and numeric values for new data?
## Warning in predict.naiveBayes(nb_model, test_data): Type mismatch between
## training and new data for variable 'SalePrice'. Did you use factors with
## numeric labels for training, and numeric values for new data?
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Media Cara
## Barata 141 61 7
## Media 3 56 19
## Cara 0 27 120
##
## Overall Statistics
##
## Accuracy : 0.7304
## 95% CI : (0.686, 0.7716)
## No Information Rate : 0.3364
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.5956
##
## Mcnemar's Test P-Value : 3.677e-13
##
## Statistics by Class:
##
## Class: Barata Class: Media Class: Cara
## Sensitivity 0.9792 0.3889 0.8219
## Specificity 0.7655 0.9241 0.9062
## Pos Pred Value 0.6746 0.7179 0.8163
## Neg Pred Value 0.9867 0.7528 0.9094
## Prevalence 0.3318 0.3318 0.3364
## Detection Rate 0.3249 0.1290 0.2765
## Detection Prevalence 0.4816 0.1797 0.3387
## Balanced Accuracy 0.8723 0.6565 0.8641
Después de probar varias iteraciones se obtuvo la mejor cantidad de resultados removiendo los puntos atípicos, en donde atípicos significa “Tienen un precio mayor a la media + 4 veces la desviación estándar”. Como se puede ver el Accuracy del modelo tuvo una ligera mejora (ascendió a 73%) y la eficiencia del modelo también aumentó levemente como se ve por la matriz de confusión.
Viendo los resultados de la matriz de confusión y las métricas de precisión, se puede notar que tiene sobreajuste. Este modelo clasifica con una sensibilidad del 96.46% y 82.16% a las casas Baratas y Caras respectivamente. Sin embargo, la clasificación de las casas Medias es del 39.88%, lo que sugiere que el modelo ha aprendido demasiado los patrones de cuertas clases y no generaliza bien.
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Media Cara
## Barata 139 42 6
## Media 5 78 20
## Cara 0 24 119
##
## Overall Statistics
##
## Accuracy : 0.776
## 95% CI : (0.7337, 0.8144)
## No Information Rate : 0.3349
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.664
##
## Mcnemar's Test P-Value : 9.592e-08
##
## Statistics by Class:
##
## Class: Barata Class: Media Class: Cara
## Sensitivity 0.9653 0.5417 0.8207
## Specificity 0.8339 0.9135 0.9167
## Pos Pred Value 0.7433 0.7573 0.8322
## Neg Pred Value 0.9797 0.8000 0.9103
## Prevalence 0.3326 0.3326 0.3349
## Detection Rate 0.3210 0.1801 0.2748
## Detection Prevalence 0.4319 0.2379 0.3303
## Balanced Accuracy 0.8996 0.7276 0.8687
Con este nuevo modelo generado mediante validación cruzada podemos ver una mejora en la Accuracy del modelo. Ahora vemos que el modelo tiene un porcentaje de accuracy del 77% siendo mayor que los modelos anteriores de Naive Bayes.
Ahora evaluaremos con diferentes hiperparámetros los modelos de clasificación y regresión.
## Warning: package 'DMwR2' was built under R version 4.4.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Warning: predict.naive_bayes(): only 36 feature(s) out of 247 defined in the naive_bayes object "best_model" are used for prediction.
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Media Cara
## Barata 142 66 2
## Media 2 66 12
## Cara 0 12 132
##
## Overall Statistics
##
## Accuracy : 0.7834
## 95% CI : (0.7416, 0.8213)
## No Information Rate : 0.3364
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.6751
##
## Mcnemar's Test P-Value : 1.957e-13
##
## Statistics by Class:
##
## Class: Barata Class: Media Class: Cara
## Sensitivity 0.9861 0.4583 0.9041
## Specificity 0.7655 0.9517 0.9583
## Pos Pred Value 0.6762 0.8250 0.9167
## Neg Pred Value 0.9911 0.7797 0.9517
## Prevalence 0.3318 0.3318 0.3364
## Detection Rate 0.3272 0.1521 0.3041
## Detection Prevalence 0.4839 0.1843 0.3318
## Balanced Accuracy 0.8758 0.7050 0.9312
El modelo de Naive Bayes no mejoró significativamente debido a varios fcatores. La matriz de confusión muestra que el modelo tiene un buen desempeño al clasificar casas baratas pero tiene dificultades para las “Medias” y “Caras”. Esto se debe al desbalanceo en la distribución de clases, favoreciendo las clases más comunes. El desempeño general del modelo, con precisión del 63%, está afectado por la suposición de independencia de caracterpisticas que Naive Bayes hace, ya que puede haber interacciones entre las caracteristicas que el modelo no está capturando.
Viendo el Accuracy del árbol de decisión y el random forest, se obtuvo que su accuracy era de 90% y 91%. Esto contrasta con lo obtenido con Naive Bayes viendo que su capacidad de predicción es peor que la de un random forest. Incluso viendo el tiempo de ejecución, se ve que el random forest se tarda menos en procesar, teniendo actualmente una diferencia de procesamiento de 5s aproximadamente.
Árboles de Decisión
Árbol multivariable
## Warning: package 'rpart' was built under R version 4.4.3
## Warning: package 'rpart.plot' was built under R version 4.4.3
## Call:
## rpart(formula = SalePrice ~ ., data = training_data)
## n= 1460
##
## CP nsplit rel error xerror xstd
## 1 0.45437625 0 1.0000000 1.0017255 0.07643058
## 2 0.12050238 1 0.5456237 0.5474099 0.04110091
## 3 0.06288535 2 0.4251214 0.4391063 0.04000157
## 4 0.03312902 3 0.3622360 0.3781786 0.02921022
## 5 0.02066528 4 0.3291070 0.3704838 0.03482459
## 6 0.01989959 5 0.3084417 0.3712601 0.03543465
## 7 0.01856908 6 0.2885421 0.3534133 0.03270556
## 8 0.01392462 7 0.2699730 0.3316936 0.02893774
## 9 0.01129700 8 0.2560484 0.3068621 0.02855251
## 10 0.01016483 9 0.2447514 0.3119753 0.02876180
## 11 0.01000000 10 0.2345866 0.3101467 0.02874102
##
## Variable importance
## OverallQual Neighborhood GarageCars KitchenQual TotalBsmtSF GarageArea
## 28 14 7 7 7 7
## GrLivArea ExterQual YearBuilt BsmtQual Foundation X2ndFlrSF
## 5 4 4 4 3 2
## TotRmsAbvGrd HouseStyle X1stFlrSF BedroomAbvGr BsmtFinSF1 Id
## 2 1 1 1 1 1
## GarageType
## 1
##
## Node number 1: 1460 observations, complexity param=0.4543763
## mean=180921.2, MSE=6.306789e+09
## left son=2 (1231 obs) right son=3 (229 obs)
## Primary splits:
## OverallQual < 7.5 to the left, improve=0.4543763, (0 missing)
## ExterQual splits as RLRL, improve=0.3786159, (0 missing)
## GarageCars < 2.5 to the left, improve=0.3650136, (0 missing)
## Neighborhood splits as LLLLLLLLLLLLLRLRLLLLRRLRR, improve=0.3460826, (0 missing)
## GrLivArea < 1488 to the left, improve=0.3280228, (0 missing)
## Surrogate splits:
## Neighborhood splits as LLLLLLLLLLLLLRLRLLLLLRLLL, agree=0.896, adj=0.336, (0 split)
## GarageCars < 2.5 to the left, agree=0.895, adj=0.332, (0 split)
## GarageArea < 690.5 to the left, agree=0.888, adj=0.288, (0 split)
## KitchenQual splits as RLLL, agree=0.884, adj=0.262, (0 split)
## TotalBsmtSF < 1560.5 to the left, agree=0.880, adj=0.236, (0 split)
##
## Node number 2: 1231 observations, complexity param=0.1205024
## mean=157832.4, MSE=2.426929e+09
## left son=4 (713 obs) right son=5 (518 obs)
## Primary splits:
## Neighborhood splits as RLLLRRRLRLLLLRLRRLLRRRLRR, improve=0.3713998, (0 missing)
## OverallQual < 6.5 to the left, improve=0.3586420, (0 missing)
## GrLivArea < 1413 to the left, improve=0.3344517, (0 missing)
## FullBath < 1.5 to the left, improve=0.3160671, (0 missing)
## KitchenQual splits as RLRL, improve=0.2793628, (0 missing)
## Surrogate splits:
## YearBuilt < 1971.5 to the left, agree=0.833, adj=0.602, (0 split)
## BsmtQual splits as RLRL, agree=0.794, adj=0.510, (0 split)
## ExterQual splits as RLRL, agree=0.773, adj=0.459, (0 split)
## Foundation splits as LLRLLL, agree=0.767, adj=0.446, (0 split)
## OverallQual < 6.5 to the left, agree=0.760, adj=0.431, (0 split)
##
## Node number 3: 229 observations, complexity param=0.06288535
## mean=305035.9, MSE=8.893039e+09
## left son=6 (168 obs) right son=7 (61 obs)
## Primary splits:
## OverallQual < 8.5 to the left, improve=0.2843315, (0 missing)
## TotalBsmtSF < 1846 to the left, improve=0.2508392, (0 missing)
## X1stFlrSF < 1829.5 to the left, improve=0.2362698, (0 missing)
## TotRmsAbvGrd < 9.5 to the left, improve=0.2297492, (0 missing)
## GarageCars < 2.5 to the left, improve=0.2272069, (0 missing)
## Surrogate splits:
## ExterQual splits as R-LL, agree=0.865, adj=0.492, (0 split)
## KitchenQual splits as R-LL, agree=0.821, adj=0.328, (0 split)
## BsmtQual splits as R-LL, agree=0.795, adj=0.230, (0 split)
## TotalBsmtSF < 1818 to the left, agree=0.786, adj=0.197, (0 split)
## MasVnrArea < 662 to the left, agree=0.773, adj=0.148, (0 split)
##
## Node number 4: 713 observations, complexity param=0.02066528
## mean=132242.5, MSE=1.226583e+09
## left son=8 (410 obs) right son=9 (303 obs)
## Primary splits:
## X1stFlrSF < 1050.5 to the left, improve=0.2175785, (0 missing)
## GrLivArea < 1377 to the left, improve=0.2131900, (0 missing)
## OverallQual < 4.5 to the left, improve=0.1819676, (0 missing)
## Fireplaces < 0.5 to the left, improve=0.1722454, (0 missing)
## TotalBsmtSF < 1050.5 to the left, improve=0.1707600, (0 missing)
## Surrogate splits:
## TotalBsmtSF < 1050.5 to the left, agree=0.850, adj=0.647, (0 split)
## GrLivArea < 1051 to the left, agree=0.735, adj=0.376, (0 split)
## GarageArea < 440.5 to the left, agree=0.669, adj=0.221, (0 split)
## LotArea < 9100.5 to the left, agree=0.663, adj=0.208, (0 split)
## BsmtFinSF1 < 561 to the left, agree=0.655, adj=0.188, (0 split)
##
## Node number 5: 518 observations, complexity param=0.03312902
## mean=193055.7, MSE=1.937105e+09
## left son=10 (350 obs) right son=11 (168 obs)
## Primary splits:
## GrLivArea < 1719 to the left, improve=0.3040093, (0 missing)
## OverallQual < 6.5 to the left, improve=0.2202643, (0 missing)
## X2ndFlrSF < 881.5 to the left, improve=0.1953041, (0 missing)
## FullBath < 1.5 to the left, improve=0.1765656, (0 missing)
## TotRmsAbvGrd < 6.5 to the left, improve=0.1569699, (0 missing)
## Surrogate splits:
## X2ndFlrSF < 855.5 to the left, agree=0.865, adj=0.583, (0 split)
## TotRmsAbvGrd < 7.5 to the left, agree=0.805, adj=0.399, (0 split)
## BedroomAbvGr < 3.5 to the left, agree=0.766, adj=0.280, (0 split)
## HouseStyle splits as RLLRLRLL, agree=0.743, adj=0.208, (0 split)
## X1stFlrSF < 1694 to the left, agree=0.716, adj=0.125, (0 split)
##
## Node number 6: 168 observations, complexity param=0.01856908
## mean=274735.5, MSE=4.058766e+09
## left son=12 (103 obs) right son=13 (65 obs)
## Primary splits:
## GrLivArea < 1971.5 to the left, improve=0.2507543, (0 missing)
## BsmtFinSF1 < 1225.5 to the left, improve=0.1998414, (0 missing)
## GarageArea < 662.5 to the left, improve=0.1815255, (0 missing)
## X1stFlrSF < 1888 to the left, improve=0.1776766, (0 missing)
## WoodDeckSF < 238.5 to the left, improve=0.1750817, (0 missing)
## Surrogate splits:
## X2ndFlrSF < 874.5 to the left, agree=0.845, adj=0.600, (0 split)
## BedroomAbvGr < 3.5 to the left, agree=0.815, adj=0.523, (0 split)
## TotRmsAbvGrd < 7.5 to the left, agree=0.815, adj=0.523, (0 split)
## HouseStyle splits as R-L--R-L, agree=0.762, adj=0.385, (0 split)
## Neighborhood splits as L----LL-L--LRR-LRL-LLL-LL, agree=0.756, adj=0.369, (0 split)
##
## Node number 7: 61 observations, complexity param=0.01989959
## mean=388486.1, MSE=1.27146e+10
## left son=14 (35 obs) right son=15 (26 obs)
## Primary splits:
## GrLivArea < 2229 to the left, improve=0.2362506, (0 missing)
## Neighborhood splits as -----L-LL----R-L-L--LR-LL, improve=0.2217872, (0 missing)
## BedroomAbvGr < 3.5 to the left, improve=0.2153626, (0 missing)
## TotalBsmtSF < 1924 to the left, improve=0.1879127, (0 missing)
## FullBath < 2.5 to the left, improve=0.1769334, (0 missing)
## Surrogate splits:
## TotRmsAbvGrd < 8.5 to the left, agree=0.869, adj=0.692, (0 split)
## HouseStyle splits as --LRRR--, agree=0.852, adj=0.654, (0 split)
## X2ndFlrSF < 284 to the left, agree=0.852, adj=0.654, (0 split)
## GarageType splits as -L-R-R, agree=0.803, adj=0.538, (0 split)
## MSSubClass < 40 to the left, agree=0.754, adj=0.423, (0 split)
##
## Node number 8: 410 observations
## mean=118198.6, MSE=7.937454e+08
##
## Node number 9: 303 observations
## mean=151245.7, MSE=1.18427e+09
##
## Node number 10: 350 observations, complexity param=0.01392462
## mean=176242.8, MSE=1.077342e+09
## left son=20 (63 obs) right son=21 (287 obs)
## Primary splits:
## GrLivArea < 1120 to the left, improve=0.3400342, (0 missing)
## TotalBsmtSF < 1272.5 to the left, improve=0.2960171, (0 missing)
## X1stFlrSF < 1199.5 to the left, improve=0.2510921, (0 missing)
## OverallQual < 5.5 to the left, improve=0.2261882, (0 missing)
## FullBath < 1.5 to the left, improve=0.2259880, (0 missing)
## Surrogate splits:
## OverallQual < 5.5 to the left, agree=0.857, adj=0.206, (0 split)
## MSZoning splits as -RLRL, agree=0.854, adj=0.190, (0 split)
## FullBath < 1.5 to the left, agree=0.851, adj=0.175, (0 split)
## TotRmsAbvGrd < 3.5 to the left, agree=0.840, adj=0.111, (0 split)
## GarageCars < 1.5 to the left, agree=0.837, adj=0.095, (0 split)
##
## Node number 11: 168 observations, complexity param=0.01016483
## mean=228082.4, MSE=1.912509e+09
## left son=22 (138 obs) right son=23 (30 obs)
## Primary splits:
## BsmtFinSF1 < 860.5 to the left, improve=0.2913054, (0 missing)
## TotalBsmtSF < 1107.5 to the left, improve=0.2841683, (0 missing)
## X1stFlrSF < 1177.5 to the left, improve=0.1852893, (0 missing)
## OverallQual < 6.5 to the left, improve=0.1838032, (0 missing)
## GrLivArea < 2126.5 to the left, improve=0.1638413, (0 missing)
## Surrogate splits:
## TotalBsmtSF < 1203.5 to the left, agree=0.869, adj=0.267, (0 split)
## MSSubClass < 35 to the right, agree=0.839, adj=0.100, (0 split)
## LotArea < 31313.5 to the left, agree=0.839, adj=0.100, (0 split)
## LandSlope splits as LRR, agree=0.839, adj=0.100, (0 split)
## X1stFlrSF < 1524 to the left, agree=0.839, adj=0.100, (0 split)
##
## Node number 12: 103 observations
## mean=249392.5, MSE=2.332109e+09
##
## Node number 13: 65 observations
## mean=314894.6, MSE=4.164354e+09
##
## Node number 14: 35 observations
## mean=341248.2, MSE=2.218086e+09
##
## Node number 15: 26 observations, complexity param=0.011297
## mean=452075.5, MSE=1.979707e+10
## left son=30 (16 obs) right son=31 (10 obs)
## Primary splits:
## Id < 642 to the left, improve=0.2020923, (0 missing)
## Exterior2nd splits as -----LRR----LRLL, improve=0.1627596, (0 missing)
## OpenPorchSF < 147 to the right, improve=0.1566605, (0 missing)
## Neighborhood splits as -------L-----R-L-L---R---, improve=0.1518467, (0 missing)
## GarageArea < 836 to the right, improve=0.1458390, (0 missing)
## Surrogate splits:
## Neighborhood splits as -------L-----R-L-L---L---, agree=0.808, adj=0.5, (0 split)
## Exterior2nd splits as -----LRR----RLLL, agree=0.769, adj=0.4, (0 split)
## GrLivArea < 2798.5 to the left, agree=0.769, adj=0.4, (0 split)
## YearBuilt < 2002 to the right, agree=0.731, adj=0.3, (0 split)
## YearRemodAdd < 1999.5 to the right, agree=0.731, adj=0.3, (0 split)
##
## Node number 20: 63 observations
## mean=135391.3, MSE=3.698856e+08
##
## Node number 21: 287 observations
## mean=185210.3, MSE=7.858899e+08
##
## Node number 22: 138 observations
## mean=217077.2, MSE=1.219806e+09
##
## Node number 23: 30 observations
## mean=278706.2, MSE=1.979047e+09
##
## Node number 30: 16 observations
## mean=402070.3, MSE=7.06213e+09
##
## Node number 31: 10 observations
## mean=532083.9, MSE=2.97708e+10
Ahora vamos a medir la precisión del modelo:
## R-squared: 0.7654134
## RMSE: 38464.11
Este modelo predice la data con un 76% de variabilidad, además su RMSE es de 38 mil dólares lo cual sigue siendo alto aunque más bajo que el de los lineales.
Árboles de varios niveles
Ahora vamos a generar árboles con varios niveles de profundidad:
## Call:
## rpart(formula = SalePrice ~ ., data = training_data)
## n= 1460
##
## CP nsplit rel error xerror xstd
## 1 0.45437625 0 1.0000000 1.0017255 0.07643058
## 2 0.12050238 1 0.5456237 0.5474099 0.04110091
## 3 0.06288535 2 0.4251214 0.4391063 0.04000157
## 4 0.03312902 3 0.3622360 0.3781786 0.02921022
## 5 0.02066528 4 0.3291070 0.3704838 0.03482459
## 6 0.01989959 5 0.3084417 0.3712601 0.03543465
## 7 0.01856908 6 0.2885421 0.3534133 0.03270556
## 8 0.01392462 7 0.2699730 0.3316936 0.02893774
## 9 0.01129700 8 0.2560484 0.3068621 0.02855251
## 10 0.01016483 9 0.2447514 0.3119753 0.02876180
## 11 0.01000000 10 0.2345866 0.3101467 0.02874102
##
## Variable importance
## OverallQual Neighborhood GarageCars KitchenQual TotalBsmtSF GarageArea
## 28 14 7 7 7 7
## GrLivArea ExterQual YearBuilt BsmtQual Foundation X2ndFlrSF
## 5 4 4 4 3 2
## TotRmsAbvGrd HouseStyle X1stFlrSF BedroomAbvGr BsmtFinSF1 Id
## 2 1 1 1 1 1
## GarageType
## 1
##
## Node number 1: 1460 observations, complexity param=0.4543763
## mean=180921.2, MSE=6.306789e+09
## left son=2 (1231 obs) right son=3 (229 obs)
## Primary splits:
## OverallQual < 7.5 to the left, improve=0.4543763, (0 missing)
## ExterQual splits as RLRL, improve=0.3786159, (0 missing)
## GarageCars < 2.5 to the left, improve=0.3650136, (0 missing)
## Neighborhood splits as LLLLLLLLLLLLLRLRLLLLRRLRR, improve=0.3460826, (0 missing)
## GrLivArea < 1488 to the left, improve=0.3280228, (0 missing)
## Surrogate splits:
## Neighborhood splits as LLLLLLLLLLLLLRLRLLLLLRLLL, agree=0.896, adj=0.336, (0 split)
## GarageCars < 2.5 to the left, agree=0.895, adj=0.332, (0 split)
## GarageArea < 690.5 to the left, agree=0.888, adj=0.288, (0 split)
## KitchenQual splits as RLLL, agree=0.884, adj=0.262, (0 split)
## TotalBsmtSF < 1560.5 to the left, agree=0.880, adj=0.236, (0 split)
##
## Node number 2: 1231 observations, complexity param=0.1205024
## mean=157832.4, MSE=2.426929e+09
## left son=4 (713 obs) right son=5 (518 obs)
## Primary splits:
## Neighborhood splits as RLLLRRRLRLLLLRLRRLLRRRLRR, improve=0.3713998, (0 missing)
## OverallQual < 6.5 to the left, improve=0.3586420, (0 missing)
## GrLivArea < 1413 to the left, improve=0.3344517, (0 missing)
## FullBath < 1.5 to the left, improve=0.3160671, (0 missing)
## KitchenQual splits as RLRL, improve=0.2793628, (0 missing)
## Surrogate splits:
## YearBuilt < 1971.5 to the left, agree=0.833, adj=0.602, (0 split)
## BsmtQual splits as RLRL, agree=0.794, adj=0.510, (0 split)
## ExterQual splits as RLRL, agree=0.773, adj=0.459, (0 split)
## Foundation splits as LLRLLL, agree=0.767, adj=0.446, (0 split)
## OverallQual < 6.5 to the left, agree=0.760, adj=0.431, (0 split)
##
## Node number 3: 229 observations, complexity param=0.06288535
## mean=305035.9, MSE=8.893039e+09
## left son=6 (168 obs) right son=7 (61 obs)
## Primary splits:
## OverallQual < 8.5 to the left, improve=0.2843315, (0 missing)
## TotalBsmtSF < 1846 to the left, improve=0.2508392, (0 missing)
## X1stFlrSF < 1829.5 to the left, improve=0.2362698, (0 missing)
## TotRmsAbvGrd < 9.5 to the left, improve=0.2297492, (0 missing)
## GarageCars < 2.5 to the left, improve=0.2272069, (0 missing)
## Surrogate splits:
## ExterQual splits as R-LL, agree=0.865, adj=0.492, (0 split)
## KitchenQual splits as R-LL, agree=0.821, adj=0.328, (0 split)
## BsmtQual splits as R-LL, agree=0.795, adj=0.230, (0 split)
## TotalBsmtSF < 1818 to the left, agree=0.786, adj=0.197, (0 split)
## MasVnrArea < 662 to the left, agree=0.773, adj=0.148, (0 split)
##
## Node number 4: 713 observations, complexity param=0.02066528
## mean=132242.5, MSE=1.226583e+09
## left son=8 (410 obs) right son=9 (303 obs)
## Primary splits:
## X1stFlrSF < 1050.5 to the left, improve=0.2175785, (0 missing)
## GrLivArea < 1377 to the left, improve=0.2131900, (0 missing)
## OverallQual < 4.5 to the left, improve=0.1819676, (0 missing)
## Fireplaces < 0.5 to the left, improve=0.1722454, (0 missing)
## TotalBsmtSF < 1050.5 to the left, improve=0.1707600, (0 missing)
## Surrogate splits:
## TotalBsmtSF < 1050.5 to the left, agree=0.850, adj=0.647, (0 split)
## GrLivArea < 1051 to the left, agree=0.735, adj=0.376, (0 split)
## GarageArea < 440.5 to the left, agree=0.669, adj=0.221, (0 split)
## LotArea < 9100.5 to the left, agree=0.663, adj=0.208, (0 split)
## BsmtFinSF1 < 561 to the left, agree=0.655, adj=0.188, (0 split)
##
## Node number 5: 518 observations, complexity param=0.03312902
## mean=193055.7, MSE=1.937105e+09
## left son=10 (350 obs) right son=11 (168 obs)
## Primary splits:
## GrLivArea < 1719 to the left, improve=0.3040093, (0 missing)
## OverallQual < 6.5 to the left, improve=0.2202643, (0 missing)
## X2ndFlrSF < 881.5 to the left, improve=0.1953041, (0 missing)
## FullBath < 1.5 to the left, improve=0.1765656, (0 missing)
## TotRmsAbvGrd < 6.5 to the left, improve=0.1569699, (0 missing)
## Surrogate splits:
## X2ndFlrSF < 855.5 to the left, agree=0.865, adj=0.583, (0 split)
## TotRmsAbvGrd < 7.5 to the left, agree=0.805, adj=0.399, (0 split)
## BedroomAbvGr < 3.5 to the left, agree=0.766, adj=0.280, (0 split)
## HouseStyle splits as RLLRLRLL, agree=0.743, adj=0.208, (0 split)
## X1stFlrSF < 1694 to the left, agree=0.716, adj=0.125, (0 split)
##
## Node number 6: 168 observations, complexity param=0.01856908
## mean=274735.5, MSE=4.058766e+09
## left son=12 (103 obs) right son=13 (65 obs)
## Primary splits:
## GrLivArea < 1971.5 to the left, improve=0.2507543, (0 missing)
## BsmtFinSF1 < 1225.5 to the left, improve=0.1998414, (0 missing)
## GarageArea < 662.5 to the left, improve=0.1815255, (0 missing)
## X1stFlrSF < 1888 to the left, improve=0.1776766, (0 missing)
## WoodDeckSF < 238.5 to the left, improve=0.1750817, (0 missing)
## Surrogate splits:
## X2ndFlrSF < 874.5 to the left, agree=0.845, adj=0.600, (0 split)
## BedroomAbvGr < 3.5 to the left, agree=0.815, adj=0.523, (0 split)
## TotRmsAbvGrd < 7.5 to the left, agree=0.815, adj=0.523, (0 split)
## HouseStyle splits as R-L--R-L, agree=0.762, adj=0.385, (0 split)
## Neighborhood splits as L----LL-L--LRR-LRL-LLL-LL, agree=0.756, adj=0.369, (0 split)
##
## Node number 7: 61 observations, complexity param=0.01989959
## mean=388486.1, MSE=1.27146e+10
## left son=14 (35 obs) right son=15 (26 obs)
## Primary splits:
## GrLivArea < 2229 to the left, improve=0.2362506, (0 missing)
## Neighborhood splits as -----L-LL----R-L-L--LR-LL, improve=0.2217872, (0 missing)
## BedroomAbvGr < 3.5 to the left, improve=0.2153626, (0 missing)
## TotalBsmtSF < 1924 to the left, improve=0.1879127, (0 missing)
## FullBath < 2.5 to the left, improve=0.1769334, (0 missing)
## Surrogate splits:
## TotRmsAbvGrd < 8.5 to the left, agree=0.869, adj=0.692, (0 split)
## HouseStyle splits as --LRRR--, agree=0.852, adj=0.654, (0 split)
## X2ndFlrSF < 284 to the left, agree=0.852, adj=0.654, (0 split)
## GarageType splits as -L-R-R, agree=0.803, adj=0.538, (0 split)
## MSSubClass < 40 to the left, agree=0.754, adj=0.423, (0 split)
##
## Node number 8: 410 observations
## mean=118198.6, MSE=7.937454e+08
##
## Node number 9: 303 observations
## mean=151245.7, MSE=1.18427e+09
##
## Node number 10: 350 observations, complexity param=0.01392462
## mean=176242.8, MSE=1.077342e+09
## left son=20 (63 obs) right son=21 (287 obs)
## Primary splits:
## GrLivArea < 1120 to the left, improve=0.3400342, (0 missing)
## TotalBsmtSF < 1272.5 to the left, improve=0.2960171, (0 missing)
## X1stFlrSF < 1199.5 to the left, improve=0.2510921, (0 missing)
## OverallQual < 5.5 to the left, improve=0.2261882, (0 missing)
## FullBath < 1.5 to the left, improve=0.2259880, (0 missing)
## Surrogate splits:
## OverallQual < 5.5 to the left, agree=0.857, adj=0.206, (0 split)
## MSZoning splits as -RLRL, agree=0.854, adj=0.190, (0 split)
## FullBath < 1.5 to the left, agree=0.851, adj=0.175, (0 split)
## TotRmsAbvGrd < 3.5 to the left, agree=0.840, adj=0.111, (0 split)
## GarageCars < 1.5 to the left, agree=0.837, adj=0.095, (0 split)
##
## Node number 11: 168 observations, complexity param=0.01016483
## mean=228082.4, MSE=1.912509e+09
## left son=22 (138 obs) right son=23 (30 obs)
## Primary splits:
## BsmtFinSF1 < 860.5 to the left, improve=0.2913054, (0 missing)
## TotalBsmtSF < 1107.5 to the left, improve=0.2841683, (0 missing)
## X1stFlrSF < 1177.5 to the left, improve=0.1852893, (0 missing)
## OverallQual < 6.5 to the left, improve=0.1838032, (0 missing)
## GrLivArea < 2126.5 to the left, improve=0.1638413, (0 missing)
## Surrogate splits:
## TotalBsmtSF < 1203.5 to the left, agree=0.869, adj=0.267, (0 split)
## MSSubClass < 35 to the right, agree=0.839, adj=0.100, (0 split)
## LotArea < 31313.5 to the left, agree=0.839, adj=0.100, (0 split)
## LandSlope splits as LRR, agree=0.839, adj=0.100, (0 split)
## X1stFlrSF < 1524 to the left, agree=0.839, adj=0.100, (0 split)
##
## Node number 12: 103 observations
## mean=249392.5, MSE=2.332109e+09
##
## Node number 13: 65 observations
## mean=314894.6, MSE=4.164354e+09
##
## Node number 14: 35 observations
## mean=341248.2, MSE=2.218086e+09
##
## Node number 15: 26 observations, complexity param=0.011297
## mean=452075.5, MSE=1.979707e+10
## left son=30 (16 obs) right son=31 (10 obs)
## Primary splits:
## Id < 642 to the left, improve=0.2020923, (0 missing)
## Exterior2nd splits as -----LRR----LRLL, improve=0.1627596, (0 missing)
## OpenPorchSF < 147 to the right, improve=0.1566605, (0 missing)
## Neighborhood splits as -------L-----R-L-L---R---, improve=0.1518467, (0 missing)
## GarageArea < 836 to the right, improve=0.1458390, (0 missing)
## Surrogate splits:
## Neighborhood splits as -------L-----R-L-L---L---, agree=0.808, adj=0.5, (0 split)
## Exterior2nd splits as -----LRR----RLLL, agree=0.769, adj=0.4, (0 split)
## GrLivArea < 2798.5 to the left, agree=0.769, adj=0.4, (0 split)
## YearBuilt < 2002 to the right, agree=0.731, adj=0.3, (0 split)
## YearRemodAdd < 1999.5 to the right, agree=0.731, adj=0.3, (0 split)
##
## Node number 20: 63 observations
## mean=135391.3, MSE=3.698856e+08
##
## Node number 21: 287 observations
## mean=185210.3, MSE=7.858899e+08
##
## Node number 22: 138 observations
## mean=217077.2, MSE=1.219806e+09
##
## Node number 23: 30 observations
## mean=278706.2, MSE=1.979047e+09
##
## Node number 30: 16 observations
## mean=402070.3, MSE=7.06213e+09
##
## Node number 31: 10 observations
## mean=532083.9, MSE=2.97708e+10
y para ver cuál es mejor lo comparamos con la data de entrenamiento:
## Árbol de 2 Niveles
## R-squared: 0.7654134
## RMSE: 38464.11
## Árbol de 3 Niveles
## R-squared: 0.7654134
## RMSE: 38464.11
## Árbol de 8 Niveles
## R-squared: 0.7654134
## RMSE: 38464.11
Cómo se puede ver, todos los árboles predicen de igual forma los datos, incluso el que solamente tiene 2 niveles!
Los resultados del modelo de regresión lineal del ejercicio pasado solamente predicen a lo sumo el 69% de los datos, lo cual me dice que es menos preciso que los modelos de árboles de decisión, los cuáles predicen un 76.5% de los datos.
Clasificación en 3 variables
Según el histograma de los datos, estos se encuentran altamente sesgados hacia la derecha:
Como la distribución sí es normal entonces si podemos realizar las divisiones dependiendo de las desviaciones estándar. Por lo que definiremos las categorías como:
- Baratas: Todas las casas menores a media - 1.5 desviaciones estándar en valor.
- Medianas: Todas las casas entre media+- 1.5 desviaciones estándar en valor.
- Caras: Todas las casas mayores a media + 1.5 desviaciones estándar en valor.
Árbol de Clasificación
Eficiencia del modelo
## Eficiencia del modelo: 0.9131478
A continuación podemos la eficiencia del modelo creado anteriormente. Obtenemos que su eficiencia de rpedicción es del 92%; superando el nivel de predición de los modelos de regresión.
Matriz de confusión del modelo de clasificación
Acontinuación se muestra la matriz de confusión del modelo:
## Real
## Predicho Baratas Caras Medianas
## Baratas 6 2 46
## Caras 3 3 56
## Medianas 115 58 1170
Podemos ver que el modelo presenta problemas acertando la clasificación de casas baratas y caras. Podemos ver la aparición de falsos negativos, viendo que las clases reales fueron mal clasificadas con otra clase. La presencia de estos falsos negativos y falsos positivos indican que el modelo no es preciso al 100%, demostrando que presenta una mejor predicción para el tipo de casa mediana.
Modelo con validación cruzada
Ahora vamos a crear un nuevo modelo ahora utilizando la validación cruzada.
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Caras Medianas
## Baratas 9 0 2
## Caras 0 6 3
## Medianas 15 6 249
##
## Overall Statistics
##
## Accuracy : 0.9103
## 95% CI : (0.8714, 0.9406)
## No Information Rate : 0.8759
## P-Value [Acc > NIR] : 0.04089
##
## Kappa : 0.5022
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Caras Class: Medianas
## Sensitivity 0.37500 0.50000 0.9803
## Specificity 0.99248 0.98921 0.4167
## Pos Pred Value 0.81818 0.66667 0.9222
## Neg Pred Value 0.94624 0.97865 0.7500
## Prevalence 0.08276 0.04138 0.8759
## Detection Rate 0.03103 0.02069 0.8586
## Detection Prevalence 0.03793 0.03103 0.9310
## Balanced Accuracy 0.68374 0.74460 0.6985
Con este nuevo modelo podemos ver una mejora significativa en comparación con el modelo anterior. Ahora en la matriz de confusión podemos notar una menor presencia de falsos negativos y falsos positivos.
## Profundidad Accuracy
## 1 3 0.8952505
## 2 5 0.9013388
## 3 7 0.9041070
Se crearan modelos con 3, 5 y 7 niveles de profundidad. Viendo la precisión de cada uno de estos árboles podemos ver que el mejor de los 3 modelos es aquel que tiene 7 niveles, esto demuestra que a mayor profundidad, se tiene una mejor clasificación.
Random Forest
## Warning: package 'randomForest' was built under R version 4.4.3
## randomForest 4.7-1.2
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
## The following object is masked from 'package:dplyr':
##
## combine
## The following object is masked from 'package:ggplot2':
##
## margin
## Modelo Accuracy
## 1 Árbol de Decisión 0.9041070
## 2 Random Forest 0.9089261
Podemos ver que los random forest presentan una mayor precisión con respecto a los árboles de decisión. Es importante destacar también que la creación de los random forest es mayor a la de los árboles de decisión entonces, viendo que la precisión en este caso no fue muy alta. Lo demuestra que se debe de tomar la decisión entre querer una mejor precisión o una mejor eficiencia algoritmica.
Modelo de Regresión Logística
Debido a que ya tenemos los datos por las entregas anteriores procedemos a elaborar un modelo de regresión logística para la variable “EsCara” utilizando validación cruzada.
## Warning in train.default(x, y, weights = w, ...): The metric "Accuracy" was not
## in the result set. ROC will be used instead.
## [1] "Modelo de EsCara"
##
## Call:
## NULL
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -8.4410 1.0141 -8.323 < 2e-16 ***
## LotArea 0.2312 0.2635 0.878 0.380169
## OverallQual 2.0755 0.4132 5.023 5.09e-07 ***
## YearBuilt 0.6113 0.4224 1.447 0.147831
## GarageCars 1.6028 0.4714 3.400 0.000673 ***
## GrLivArea 1.0173 0.3026 3.362 0.000775 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 369.23 on 1023 degrees of freedom
## Residual deviance: 129.42 on 1018 degrees of freedom
## AIC: 141.42
##
## Number of Fisher Scoring iterations: 9
Analizando los coeficientes podemos ver que varias de las variables utilizadas tienen un p-value menor a 0.05, pero no son todas, LotArea y YearBuilt tienen un p value demasiado elevado, lo que me lleva a pensar que realmente no necesariamente se correlacionan con el precio de la vivienda.
Utilizando el modelo con el conjunto de verificación podemos ver que:
## Confusion Matrix and Statistics
##
## Reference
## Prediction No Sí
## No 414 8
## Sí 4 10
##
## Accuracy : 0.9725
## 95% CI : (0.9524, 0.9857)
## No Information Rate : 0.9587
## P-Value [Acc > NIR] : 0.08708
##
## Kappa : 0.6109
##
## Mcnemar's Test P-Value : 0.38648
##
## Sensitivity : 0.9904
## Specificity : 0.5556
## Pos Pred Value : 0.9810
## Neg Pred Value : 0.7143
## Prevalence : 0.9587
## Detection Rate : 0.9495
## Detection Prevalence : 0.9679
## Balanced Accuracy : 0.7730
##
## 'Positive' Class : No
##
Viendo los resultados del modelo, podemos ver que aunque el “Accuracy” es muy alto, realmente el modelo es medio malo, ya que nuestro Balanced Accuracy apenas llega a 77%, esto se debe a que realmente la cantidad de casas que cumplen nuestra definición de “cara” es extremadamente alta (2 desviaciónes estándar por encima de la media). Por lo tanto tenemos que balancear la muestra para que el modelo pueda aprender características sobre este conjunto de datos reducido.
## Warning: package 'ROSE' was built under R version 4.4.3
## Loaded ROSE 0.0-4
## Warning in train.default(x, y, weights = w, ...): The metric "Precision-Recall
## AUC" was not in the result set. ROC will be used instead.
## [1] "Modelo de EsCara"
## Confusion Matrix and Statistics
##
## Reference
## Prediction No Sí
## No 190 10
## Sí 22 215
##
## Accuracy : 0.9268
## 95% CI : (0.8982, 0.9494)
## No Information Rate : 0.5149
## P-Value [Acc > NIR] : < 2e-16
##
## Kappa : 0.8532
##
## Mcnemar's Test P-Value : 0.05183
##
## Sensitivity : 0.8962
## Specificity : 0.9556
## Pos Pred Value : 0.9500
## Neg Pred Value : 0.9072
## Prevalence : 0.4851
## Detection Rate : 0.4348
## Detection Prevalence : 0.4577
## Balanced Accuracy : 0.9259
##
## 'Positive' Class : No
##
¡Podemos ver que este modelo se comporta de una manera mucho mejor al anterior! Aunque el accuracy normal disminuyó considerablemente el accuracy balanceado aumentó a 92%! Esto se debe principalmente a que nuestro modelo ya es capaz de identificar muchas más casas que sí son consideradas caras, pueso que las incluimos más seguido dentro del dataset.
Análisis de Overfitting/Underfitting
¡Para analizar el overfitting/underfitting del modelo necesitamos evaluarlo con los datos de entrenamiento y comparar sus resultados con respecto a los datos de verificación!
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
## [1] "Usando data de entrenamiento"
## Training for 10% (n = 71)
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Training for 20% (n = 143)
## Training for 30% (n = 215)
## Training for 40% (n = 286)
## Training for 50% (n = 358)
## Training for 60% (n = 430)
## Training for 70% (n = 501)
## Training for 80% (n = 573)
## Training for 90% (n = 645)
## Training for 100% (n = 717)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Como podemos ver, las curvas tanto de validación como de entrenamiento se siguen muy cercanamente en los rangos cercanos a 300 datos y de 500 en adelante. En el final, aunque no convergen se puede ver que sí se encuentran muy cercanos entre sí por lo tanto no hay Overfitting. Tampoco creemos que haya underfitting, puesto que aunque sí están juntas la mayoría del tiempo, el valor de accuracy es demasiado alto (mayor a 94%). Por lo que consideramos que el modelo realmente sí aprendió de forma correcta luego de aplicarle un resampling a los datos de entrada para que no tuviera despreciara minorías.
Eficiencia del modelo
Es importante determinar como podemos mejorar nuestro modelo y esto se puede hacer modificando los hiperparametros usados. En la implementación actual del modelo de regresión logística utilizando el método “glm” dentro de la función train de la librería caret, no se puede realizar ajustes automáticos de hiperparámetros. Esto se debe a que la función glm en R, implementa la regresión logísitca estándar, no posee hiperparámetros intrínsecos que puedan ser optimizados.
En este caso el único “tunning” que se podría hacer es volver a realizar la ingeniería de caractrísticas y cambiar la selección de las variables predictoras pero esto involucraría cambiar el resto de los modelos que se hicieron en entregas anteriores por lo que no se procedera con este método y se dejara el tunning estandar que ofrece el modelo.
## Warning in train.default(x, y, weights = w, ...): The metric "Precision-Recall
## AUC" was not in the result set. ROC will be used instead.
## [1] "Modelo de EsCara"
## Confusion Matrix and Statistics
##
## Reference
## Prediction No Sí
## No 208 22
## Sí 18 188
##
## Accuracy : 0.9083
## 95% CI : (0.8772, 0.9336)
## No Information Rate : 0.5183
## P-Value [Acc > NIR] : <2e-16
##
## Kappa : 0.8161
##
## Mcnemar's Test P-Value : 0.6353
##
## Sensitivity : 0.9204
## Specificity : 0.8952
## Pos Pred Value : 0.9043
## Neg Pred Value : 0.9126
## Prevalence : 0.5183
## Detection Rate : 0.4771
## Detection Prevalence : 0.5275
## Balanced Accuracy : 0.9078
##
## 'Positive' Class : No
##
Viendo la matriz de confusión obtenida vemos que estamos obteniendo más errores al predecir que una casa es cara, teniendo 22 casos (falsos negativos) que las casas si eran caras pero las clasifico como “No”. Luego vemos que que hubo 10 casos (falsos positivos) que fueron mal clasificados. Entendemos que estos errores implican en que se afecta en la eficiencia de las ventas demostrando posibles falsos datos a los compradores haciendo que exista posibles pérdidas en las oportunidades de venta.
## profvis: code exited with error:
En lo que respecta al tiempo y la memoria consumida se ve que para este modelo estos vaores son significativamente bajos. Se utilizo la libreria profviz para analizar estos datos y se obtuvo que el modelo consume un total de 17 MB que se asocia como una cantidad baja de memoria; por otro lado, se tiene un tiempo de ejecución total de 150 ms. La obtención de ambos valores bajos (memoria consumida y tiempo) indica una eficiencia algoritmica por parte del modelo mostrando una rápida y economica ejecución de este.
Teniendo los datos anteriores seria bueno analizar los modelos implementados para determinar el mejor. Esto se puede conocer rápido al analizar las matrices de confusiones que se presentaron a lo largo del reporte. En este caso tenemos un modelo inicial y su versión mejorada, se tiene que el modelo mejorado presenta un mejor rendimiento lo que hace que sea este el mejor modelo.
Comparación de modelos
Actualmente solo tenemos modelos que determinan si la una casa es cara o no, vamos a actualizarlo para deducir la variable “Categoría”. A continuación se presenta la matriz de confusión obtenida por el modelo.
## # weights: 30 (18 variable)
## initial value 1285.376378
## iter 10 value 262.260641
## iter 20 value 251.642534
## final value 251.629335
## converged
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Caras Medianas
## Baratas 13 0 3
## Caras 0 7 1
## Medianas 11 5 250
##
## Overall Statistics
##
## Accuracy : 0.931
## 95% CI : (0.8955, 0.9574)
## No Information Rate : 0.8759
## P-Value [Acc > NIR] : 0.001599
##
## Kappa : 0.6388
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Caras Class: Medianas
## Sensitivity 0.54167 0.58333 0.9843
## Specificity 0.98872 0.99640 0.5556
## Pos Pred Value 0.81250 0.87500 0.9398
## Neg Pred Value 0.95985 0.98227 0.8333
## Prevalence 0.08276 0.04138 0.8759
## Detection Rate 0.04483 0.02414 0.8621
## Detection Prevalence 0.05517 0.02759 0.9172
## Balanced Accuracy 0.76519 0.78987 0.7699
A continuación se presentaran las matrices de confusión de los modelos que se realizaron en reportes anteriores.
- KNN:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Cara Mediana
## Barata 0 0 0
## Cara 0 13 0
## Mediana 4 21 399
##
## Overall Statistics
##
## Accuracy : 0.9428
## 95% CI : (0.9167, 0.9626)
## No Information Rate : 0.913
## P-Value [Acc > NIR] : 0.0132
##
## Kappa : 0.4883
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Cara Class: Mediana
## Sensitivity 0.000000 0.38235 1.0000
## Specificity 1.000000 1.00000 0.3421
## Pos Pred Value NaN 1.00000 0.9410
## Neg Pred Value 0.990847 0.95047 1.0000
## Prevalence 0.009153 0.07780 0.9130
## Detection Rate 0.000000 0.02975 0.9130
## Detection Prevalence 0.000000 0.02975 0.9703
## Balanced Accuracy 0.500000 0.69118 0.6711
- Naive Bayes:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Media Cara
## Barata 140 54 8
## Media 4 60 23
## Cara 0 30 118
##
## Overall Statistics
##
## Accuracy : 0.7277
## 95% CI : (0.6834, 0.7689)
## No Information Rate : 0.341
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.5915
##
## Mcnemar's Test P-Value : 2.954e-11
##
## Statistics by Class:
##
## Class: Barata Class: Media Class: Cara
## Sensitivity 0.9722 0.4167 0.7919
## Specificity 0.7884 0.9078 0.8958
## Pos Pred Value 0.6931 0.6897 0.7973
## Neg Pred Value 0.9830 0.7600 0.8927
## Prevalence 0.3295 0.3295 0.3410
## Detection Rate 0.3204 0.1373 0.2700
## Detection Prevalence 0.4622 0.1991 0.3387
## Balanced Accuracy 0.8803 0.6623 0.8439
- Árbol de regresión:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Caras Medianas
## Baratas 9 0 2
## Caras 0 6 3
## Medianas 15 6 249
##
## Overall Statistics
##
## Accuracy : 0.9103
## 95% CI : (0.8714, 0.9406)
## No Information Rate : 0.8759
## P-Value [Acc > NIR] : 0.04089
##
## Kappa : 0.5022
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Caras Class: Medianas
## Sensitivity 0.37500 0.50000 0.9803
## Specificity 0.99248 0.98921 0.4167
## Pos Pred Value 0.81818 0.66667 0.9222
## Neg Pred Value 0.94624 0.97865 0.7500
## Prevalence 0.08276 0.04138 0.8759
## Detection Rate 0.03103 0.02069 0.8586
## Detection Prevalence 0.03793 0.03103 0.9310
## Balanced Accuracy 0.68374 0.74460 0.6985
Análisis de modelos
Al comparar las matrices de confusión para la predicción de la variable “Category”, la Regresión Logística y el KNN exhiben las mayores exactitudes generales, ambas al rededor del 93-94%. Haciendo un analisis más profundo se ve la regresión logística presenta una mayor cooncordancia en sus datos presentados. El modelo de Naive Bayes presenta una excatitud significativamente menor (71.4%). El Árbol de Regresión se sitúa con una exactitud del 91.03%, quedando por debajo de los otros modelos mejores.
En lo que respecta a los errores presentado por cada modelo podemos ver lo siguiente. La Regresión Logística tiende a confundir las casas “Medianas” con “Baratas” y “Caras” en mayor medida. EL modelo de KNN muestra un patrón de error mayor al no predecir correctamente ningún caso de la categoría “Barata” y confundir significativamente las casas “Medianas” con “Caras”. El Naive Bayes presenta errores distribuidos entre las clases, con una notable confusión entre “Medianas” y “Baratas”. El Árbol de Regresión también muestra una tendecia a confundir “Medianas” con “Baratas” y “Caras”.
En los tiempos de ejecución ningún modelo se tardo excesivamente mucho. El único modelo que tuvo una ejecución mas longeva fue el Árbol de regresión pero su tiempo agregado no se separa mucho del de los otros modelos.
Teniendo todo el análisis anterior, tenemos que el modelo de regresión logística es el mejor modelo para predecir la variable “Category”, ofreciendo un mejor equilibrio entre un alto rendimiento predictivo y una concordancia moderada.
Modelos de Regresión SVM
Las transformaciones que se hicieron en el dataset involucraron la eliminación de los valores NA del dataset junto a la normalización de las variables numéricas. De igual forma para mejorar el rendimiento en el entrenamiento de los modelos que se harán a continuación, se mantuvo en el dataset unicamente la variable objetivo junto a las variables predictoras.
A continuación se generan tres modelos de SVM: lineal, radial y polinomial. Cada modelo es testeado mediante diferentes parametros de forma automatica.
## + Fold01: C= 0.1
## - Fold01: C= 0.1
## + Fold01: C= 1.0
## - Fold01: C= 1.0
## + Fold01: C=10.0
## - Fold01: C=10.0
## + Fold02: C= 0.1
## - Fold02: C= 0.1
## + Fold02: C= 1.0
## - Fold02: C= 1.0
## + Fold02: C=10.0
## - Fold02: C=10.0
## + Fold03: C= 0.1
## - Fold03: C= 0.1
## + Fold03: C= 1.0
## - Fold03: C= 1.0
## + Fold03: C=10.0
## - Fold03: C=10.0
## + Fold04: C= 0.1
## - Fold04: C= 0.1
## + Fold04: C= 1.0
## - Fold04: C= 1.0
## + Fold04: C=10.0
## - Fold04: C=10.0
## + Fold05: C= 0.1
## - Fold05: C= 0.1
## + Fold05: C= 1.0
## - Fold05: C= 1.0
## + Fold05: C=10.0
## - Fold05: C=10.0
## + Fold06: C= 0.1
## - Fold06: C= 0.1
## + Fold06: C= 1.0
## - Fold06: C= 1.0
## + Fold06: C=10.0
## - Fold06: C=10.0
## + Fold07: C= 0.1
## - Fold07: C= 0.1
## + Fold07: C= 1.0
## - Fold07: C= 1.0
## + Fold07: C=10.0
## - Fold07: C=10.0
## + Fold08: C= 0.1
## - Fold08: C= 0.1
## + Fold08: C= 1.0
## - Fold08: C= 1.0
## + Fold08: C=10.0
## - Fold08: C=10.0
## + Fold09: C= 0.1
## - Fold09: C= 0.1
## + Fold09: C= 1.0
## - Fold09: C= 1.0
## + Fold09: C=10.0
## - Fold09: C=10.0
## + Fold10: C= 0.1
## - Fold10: C= 0.1
## + Fold10: C= 1.0
## - Fold10: C= 1.0
## + Fold10: C=10.0
## - Fold10: C=10.0
## Aggregating results
## Selecting tuning parameters
## Fitting C = 0.1 on full training set
## + Fold01: C= 0.1, sigma=0.01
## - Fold01: C= 0.1, sigma=0.01
## + Fold01: C= 1.0, sigma=0.01
## - Fold01: C= 1.0, sigma=0.01
## + Fold01: C=10.0, sigma=0.01
## - Fold01: C=10.0, sigma=0.01
## + Fold01: C= 0.1, sigma=0.10
## - Fold01: C= 0.1, sigma=0.10
## + Fold01: C= 1.0, sigma=0.10
## - Fold01: C= 1.0, sigma=0.10
## + Fold01: C=10.0, sigma=0.10
## - Fold01: C=10.0, sigma=0.10
## + Fold01: C= 0.1, sigma=1.00
## - Fold01: C= 0.1, sigma=1.00
## + Fold01: C= 1.0, sigma=1.00
## - Fold01: C= 1.0, sigma=1.00
## + Fold01: C=10.0, sigma=1.00
## - Fold01: C=10.0, sigma=1.00
## + Fold02: C= 0.1, sigma=0.01
## - Fold02: C= 0.1, sigma=0.01
## + Fold02: C= 1.0, sigma=0.01
## - Fold02: C= 1.0, sigma=0.01
## + Fold02: C=10.0, sigma=0.01
## - Fold02: C=10.0, sigma=0.01
## + Fold02: C= 0.1, sigma=0.10
## - Fold02: C= 0.1, sigma=0.10
## + Fold02: C= 1.0, sigma=0.10
## - Fold02: C= 1.0, sigma=0.10
## + Fold02: C=10.0, sigma=0.10
## - Fold02: C=10.0, sigma=0.10
## + Fold02: C= 0.1, sigma=1.00
## - Fold02: C= 0.1, sigma=1.00
## + Fold02: C= 1.0, sigma=1.00
## - Fold02: C= 1.0, sigma=1.00
## + Fold02: C=10.0, sigma=1.00
## - Fold02: C=10.0, sigma=1.00
## + Fold03: C= 0.1, sigma=0.01
## - Fold03: C= 0.1, sigma=0.01
## + Fold03: C= 1.0, sigma=0.01
## - Fold03: C= 1.0, sigma=0.01
## + Fold03: C=10.0, sigma=0.01
## - Fold03: C=10.0, sigma=0.01
## + Fold03: C= 0.1, sigma=0.10
## - Fold03: C= 0.1, sigma=0.10
## + Fold03: C= 1.0, sigma=0.10
## - Fold03: C= 1.0, sigma=0.10
## + Fold03: C=10.0, sigma=0.10
## - Fold03: C=10.0, sigma=0.10
## + Fold03: C= 0.1, sigma=1.00
## - Fold03: C= 0.1, sigma=1.00
## + Fold03: C= 1.0, sigma=1.00
## - Fold03: C= 1.0, sigma=1.00
## + Fold03: C=10.0, sigma=1.00
## - Fold03: C=10.0, sigma=1.00
## + Fold04: C= 0.1, sigma=0.01
## - Fold04: C= 0.1, sigma=0.01
## + Fold04: C= 1.0, sigma=0.01
## - Fold04: C= 1.0, sigma=0.01
## + Fold04: C=10.0, sigma=0.01
## - Fold04: C=10.0, sigma=0.01
## + Fold04: C= 0.1, sigma=0.10
## - Fold04: C= 0.1, sigma=0.10
## + Fold04: C= 1.0, sigma=0.10
## - Fold04: C= 1.0, sigma=0.10
## + Fold04: C=10.0, sigma=0.10
## - Fold04: C=10.0, sigma=0.10
## + Fold04: C= 0.1, sigma=1.00
## - Fold04: C= 0.1, sigma=1.00
## + Fold04: C= 1.0, sigma=1.00
## - Fold04: C= 1.0, sigma=1.00
## + Fold04: C=10.0, sigma=1.00
## - Fold04: C=10.0, sigma=1.00
## + Fold05: C= 0.1, sigma=0.01
## - Fold05: C= 0.1, sigma=0.01
## + Fold05: C= 1.0, sigma=0.01
## - Fold05: C= 1.0, sigma=0.01
## + Fold05: C=10.0, sigma=0.01
## - Fold05: C=10.0, sigma=0.01
## + Fold05: C= 0.1, sigma=0.10
## - Fold05: C= 0.1, sigma=0.10
## + Fold05: C= 1.0, sigma=0.10
## - Fold05: C= 1.0, sigma=0.10
## + Fold05: C=10.0, sigma=0.10
## - Fold05: C=10.0, sigma=0.10
## + Fold05: C= 0.1, sigma=1.00
## - Fold05: C= 0.1, sigma=1.00
## + Fold05: C= 1.0, sigma=1.00
## - Fold05: C= 1.0, sigma=1.00
## + Fold05: C=10.0, sigma=1.00
## - Fold05: C=10.0, sigma=1.00
## + Fold06: C= 0.1, sigma=0.01
## - Fold06: C= 0.1, sigma=0.01
## + Fold06: C= 1.0, sigma=0.01
## - Fold06: C= 1.0, sigma=0.01
## + Fold06: C=10.0, sigma=0.01
## - Fold06: C=10.0, sigma=0.01
## + Fold06: C= 0.1, sigma=0.10
## - Fold06: C= 0.1, sigma=0.10
## + Fold06: C= 1.0, sigma=0.10
## - Fold06: C= 1.0, sigma=0.10
## + Fold06: C=10.0, sigma=0.10
## - Fold06: C=10.0, sigma=0.10
## + Fold06: C= 0.1, sigma=1.00
## - Fold06: C= 0.1, sigma=1.00
## + Fold06: C= 1.0, sigma=1.00
## - Fold06: C= 1.0, sigma=1.00
## + Fold06: C=10.0, sigma=1.00
## - Fold06: C=10.0, sigma=1.00
## + Fold07: C= 0.1, sigma=0.01
## - Fold07: C= 0.1, sigma=0.01
## + Fold07: C= 1.0, sigma=0.01
## - Fold07: C= 1.0, sigma=0.01
## + Fold07: C=10.0, sigma=0.01
## - Fold07: C=10.0, sigma=0.01
## + Fold07: C= 0.1, sigma=0.10
## - Fold07: C= 0.1, sigma=0.10
## + Fold07: C= 1.0, sigma=0.10
## - Fold07: C= 1.0, sigma=0.10
## + Fold07: C=10.0, sigma=0.10
## - Fold07: C=10.0, sigma=0.10
## + Fold07: C= 0.1, sigma=1.00
## - Fold07: C= 0.1, sigma=1.00
## + Fold07: C= 1.0, sigma=1.00
## - Fold07: C= 1.0, sigma=1.00
## + Fold07: C=10.0, sigma=1.00
## - Fold07: C=10.0, sigma=1.00
## + Fold08: C= 0.1, sigma=0.01
## - Fold08: C= 0.1, sigma=0.01
## + Fold08: C= 1.0, sigma=0.01
## - Fold08: C= 1.0, sigma=0.01
## + Fold08: C=10.0, sigma=0.01
## - Fold08: C=10.0, sigma=0.01
## + Fold08: C= 0.1, sigma=0.10
## - Fold08: C= 0.1, sigma=0.10
## + Fold08: C= 1.0, sigma=0.10
## - Fold08: C= 1.0, sigma=0.10
## + Fold08: C=10.0, sigma=0.10
## - Fold08: C=10.0, sigma=0.10
## + Fold08: C= 0.1, sigma=1.00
## - Fold08: C= 0.1, sigma=1.00
## + Fold08: C= 1.0, sigma=1.00
## - Fold08: C= 1.0, sigma=1.00
## + Fold08: C=10.0, sigma=1.00
## - Fold08: C=10.0, sigma=1.00
## + Fold09: C= 0.1, sigma=0.01
## - Fold09: C= 0.1, sigma=0.01
## + Fold09: C= 1.0, sigma=0.01
## - Fold09: C= 1.0, sigma=0.01
## + Fold09: C=10.0, sigma=0.01
## - Fold09: C=10.0, sigma=0.01
## + Fold09: C= 0.1, sigma=0.10
## - Fold09: C= 0.1, sigma=0.10
## + Fold09: C= 1.0, sigma=0.10
## - Fold09: C= 1.0, sigma=0.10
## + Fold09: C=10.0, sigma=0.10
## - Fold09: C=10.0, sigma=0.10
## + Fold09: C= 0.1, sigma=1.00
## - Fold09: C= 0.1, sigma=1.00
## + Fold09: C= 1.0, sigma=1.00
## - Fold09: C= 1.0, sigma=1.00
## + Fold09: C=10.0, sigma=1.00
## - Fold09: C=10.0, sigma=1.00
## + Fold10: C= 0.1, sigma=0.01
## - Fold10: C= 0.1, sigma=0.01
## + Fold10: C= 1.0, sigma=0.01
## - Fold10: C= 1.0, sigma=0.01
## + Fold10: C=10.0, sigma=0.01
## - Fold10: C=10.0, sigma=0.01
## + Fold10: C= 0.1, sigma=0.10
## - Fold10: C= 0.1, sigma=0.10
## + Fold10: C= 1.0, sigma=0.10
## - Fold10: C= 1.0, sigma=0.10
## + Fold10: C=10.0, sigma=0.10
## - Fold10: C=10.0, sigma=0.10
## + Fold10: C= 0.1, sigma=1.00
## - Fold10: C= 0.1, sigma=1.00
## + Fold10: C= 1.0, sigma=1.00
## - Fold10: C= 1.0, sigma=1.00
## + Fold10: C=10.0, sigma=1.00
## - Fold10: C=10.0, sigma=1.00
## Aggregating results
## Selecting tuning parameters
## Fitting sigma = 0.01, C = 0.1 on full training set
## + Fold01: degree=2, scale=0.1, C= 0.1
## - Fold01: degree=2, scale=0.1, C= 0.1
## + Fold01: degree=3, scale=0.1, C= 0.1
## - Fold01: degree=3, scale=0.1, C= 0.1
## + Fold01: degree=2, scale=1.0, C= 0.1
## - Fold01: degree=2, scale=1.0, C= 0.1
## + Fold01: degree=3, scale=1.0, C= 0.1
## - Fold01: degree=3, scale=1.0, C= 0.1
## + Fold01: degree=2, scale=0.1, C= 1.0
## - Fold01: degree=2, scale=0.1, C= 1.0
## + Fold01: degree=3, scale=0.1, C= 1.0
## - Fold01: degree=3, scale=0.1, C= 1.0
## + Fold01: degree=2, scale=1.0, C= 1.0
## - Fold01: degree=2, scale=1.0, C= 1.0
## + Fold01: degree=3, scale=1.0, C= 1.0
## - Fold01: degree=3, scale=1.0, C= 1.0
## + Fold01: degree=2, scale=0.1, C=10.0
## - Fold01: degree=2, scale=0.1, C=10.0
## + Fold01: degree=3, scale=0.1, C=10.0
## - Fold01: degree=3, scale=0.1, C=10.0
## + Fold01: degree=2, scale=1.0, C=10.0
## - Fold01: degree=2, scale=1.0, C=10.0
## + Fold01: degree=3, scale=1.0, C=10.0
## - Fold01: degree=3, scale=1.0, C=10.0
## + Fold02: degree=2, scale=0.1, C= 0.1
## - Fold02: degree=2, scale=0.1, C= 0.1
## + Fold02: degree=3, scale=0.1, C= 0.1
## - Fold02: degree=3, scale=0.1, C= 0.1
## + Fold02: degree=2, scale=1.0, C= 0.1
## - Fold02: degree=2, scale=1.0, C= 0.1
## + Fold02: degree=3, scale=1.0, C= 0.1
## - Fold02: degree=3, scale=1.0, C= 0.1
## + Fold02: degree=2, scale=0.1, C= 1.0
## - Fold02: degree=2, scale=0.1, C= 1.0
## + Fold02: degree=3, scale=0.1, C= 1.0
## - Fold02: degree=3, scale=0.1, C= 1.0
## + Fold02: degree=2, scale=1.0, C= 1.0
## - Fold02: degree=2, scale=1.0, C= 1.0
## + Fold02: degree=3, scale=1.0, C= 1.0
## - Fold02: degree=3, scale=1.0, C= 1.0
## + Fold02: degree=2, scale=0.1, C=10.0
## - Fold02: degree=2, scale=0.1, C=10.0
## + Fold02: degree=3, scale=0.1, C=10.0
## - Fold02: degree=3, scale=0.1, C=10.0
## + Fold02: degree=2, scale=1.0, C=10.0
## - Fold02: degree=2, scale=1.0, C=10.0
## + Fold02: degree=3, scale=1.0, C=10.0
## - Fold02: degree=3, scale=1.0, C=10.0
## + Fold03: degree=2, scale=0.1, C= 0.1
## - Fold03: degree=2, scale=0.1, C= 0.1
## + Fold03: degree=3, scale=0.1, C= 0.1
## - Fold03: degree=3, scale=0.1, C= 0.1
## + Fold03: degree=2, scale=1.0, C= 0.1
## - Fold03: degree=2, scale=1.0, C= 0.1
## + Fold03: degree=3, scale=1.0, C= 0.1
## - Fold03: degree=3, scale=1.0, C= 0.1
## + Fold03: degree=2, scale=0.1, C= 1.0
## - Fold03: degree=2, scale=0.1, C= 1.0
## + Fold03: degree=3, scale=0.1, C= 1.0
## - Fold03: degree=3, scale=0.1, C= 1.0
## + Fold03: degree=2, scale=1.0, C= 1.0
## - Fold03: degree=2, scale=1.0, C= 1.0
## + Fold03: degree=3, scale=1.0, C= 1.0
## - Fold03: degree=3, scale=1.0, C= 1.0
## + Fold03: degree=2, scale=0.1, C=10.0
## - Fold03: degree=2, scale=0.1, C=10.0
## + Fold03: degree=3, scale=0.1, C=10.0
## - Fold03: degree=3, scale=0.1, C=10.0
## + Fold03: degree=2, scale=1.0, C=10.0
## - Fold03: degree=2, scale=1.0, C=10.0
## + Fold03: degree=3, scale=1.0, C=10.0
## - Fold03: degree=3, scale=1.0, C=10.0
## + Fold04: degree=2, scale=0.1, C= 0.1
## - Fold04: degree=2, scale=0.1, C= 0.1
## + Fold04: degree=3, scale=0.1, C= 0.1
## - Fold04: degree=3, scale=0.1, C= 0.1
## + Fold04: degree=2, scale=1.0, C= 0.1
## - Fold04: degree=2, scale=1.0, C= 0.1
## + Fold04: degree=3, scale=1.0, C= 0.1
## - Fold04: degree=3, scale=1.0, C= 0.1
## + Fold04: degree=2, scale=0.1, C= 1.0
## - Fold04: degree=2, scale=0.1, C= 1.0
## + Fold04: degree=3, scale=0.1, C= 1.0
## - Fold04: degree=3, scale=0.1, C= 1.0
## + Fold04: degree=2, scale=1.0, C= 1.0
## - Fold04: degree=2, scale=1.0, C= 1.0
## + Fold04: degree=3, scale=1.0, C= 1.0
## - Fold04: degree=3, scale=1.0, C= 1.0
## + Fold04: degree=2, scale=0.1, C=10.0
## - Fold04: degree=2, scale=0.1, C=10.0
## + Fold04: degree=3, scale=0.1, C=10.0
## - Fold04: degree=3, scale=0.1, C=10.0
## + Fold04: degree=2, scale=1.0, C=10.0
## - Fold04: degree=2, scale=1.0, C=10.0
## + Fold04: degree=3, scale=1.0, C=10.0
## - Fold04: degree=3, scale=1.0, C=10.0
## + Fold05: degree=2, scale=0.1, C= 0.1
## - Fold05: degree=2, scale=0.1, C= 0.1
## + Fold05: degree=3, scale=0.1, C= 0.1
## - Fold05: degree=3, scale=0.1, C= 0.1
## + Fold05: degree=2, scale=1.0, C= 0.1
## - Fold05: degree=2, scale=1.0, C= 0.1
## + Fold05: degree=3, scale=1.0, C= 0.1
## - Fold05: degree=3, scale=1.0, C= 0.1
## + Fold05: degree=2, scale=0.1, C= 1.0
## - Fold05: degree=2, scale=0.1, C= 1.0
## + Fold05: degree=3, scale=0.1, C= 1.0
## - Fold05: degree=3, scale=0.1, C= 1.0
## + Fold05: degree=2, scale=1.0, C= 1.0
## - Fold05: degree=2, scale=1.0, C= 1.0
## + Fold05: degree=3, scale=1.0, C= 1.0
## - Fold05: degree=3, scale=1.0, C= 1.0
## + Fold05: degree=2, scale=0.1, C=10.0
## - Fold05: degree=2, scale=0.1, C=10.0
## + Fold05: degree=3, scale=0.1, C=10.0
## - Fold05: degree=3, scale=0.1, C=10.0
## + Fold05: degree=2, scale=1.0, C=10.0
## - Fold05: degree=2, scale=1.0, C=10.0
## + Fold05: degree=3, scale=1.0, C=10.0
## - Fold05: degree=3, scale=1.0, C=10.0
## + Fold06: degree=2, scale=0.1, C= 0.1
## - Fold06: degree=2, scale=0.1, C= 0.1
## + Fold06: degree=3, scale=0.1, C= 0.1
## - Fold06: degree=3, scale=0.1, C= 0.1
## + Fold06: degree=2, scale=1.0, C= 0.1
## - Fold06: degree=2, scale=1.0, C= 0.1
## + Fold06: degree=3, scale=1.0, C= 0.1
## - Fold06: degree=3, scale=1.0, C= 0.1
## + Fold06: degree=2, scale=0.1, C= 1.0
## - Fold06: degree=2, scale=0.1, C= 1.0
## + Fold06: degree=3, scale=0.1, C= 1.0
## - Fold06: degree=3, scale=0.1, C= 1.0
## + Fold06: degree=2, scale=1.0, C= 1.0
## - Fold06: degree=2, scale=1.0, C= 1.0
## + Fold06: degree=3, scale=1.0, C= 1.0
## - Fold06: degree=3, scale=1.0, C= 1.0
## + Fold06: degree=2, scale=0.1, C=10.0
## - Fold06: degree=2, scale=0.1, C=10.0
## + Fold06: degree=3, scale=0.1, C=10.0
## - Fold06: degree=3, scale=0.1, C=10.0
## + Fold06: degree=2, scale=1.0, C=10.0
## - Fold06: degree=2, scale=1.0, C=10.0
## + Fold06: degree=3, scale=1.0, C=10.0
## - Fold06: degree=3, scale=1.0, C=10.0
## + Fold07: degree=2, scale=0.1, C= 0.1
## - Fold07: degree=2, scale=0.1, C= 0.1
## + Fold07: degree=3, scale=0.1, C= 0.1
## - Fold07: degree=3, scale=0.1, C= 0.1
## + Fold07: degree=2, scale=1.0, C= 0.1
## - Fold07: degree=2, scale=1.0, C= 0.1
## + Fold07: degree=3, scale=1.0, C= 0.1
## - Fold07: degree=3, scale=1.0, C= 0.1
## + Fold07: degree=2, scale=0.1, C= 1.0
## - Fold07: degree=2, scale=0.1, C= 1.0
## + Fold07: degree=3, scale=0.1, C= 1.0
## - Fold07: degree=3, scale=0.1, C= 1.0
## + Fold07: degree=2, scale=1.0, C= 1.0
## - Fold07: degree=2, scale=1.0, C= 1.0
## + Fold07: degree=3, scale=1.0, C= 1.0
## - Fold07: degree=3, scale=1.0, C= 1.0
## + Fold07: degree=2, scale=0.1, C=10.0
## - Fold07: degree=2, scale=0.1, C=10.0
## + Fold07: degree=3, scale=0.1, C=10.0
## - Fold07: degree=3, scale=0.1, C=10.0
## + Fold07: degree=2, scale=1.0, C=10.0
## - Fold07: degree=2, scale=1.0, C=10.0
## + Fold07: degree=3, scale=1.0, C=10.0
## - Fold07: degree=3, scale=1.0, C=10.0
## + Fold08: degree=2, scale=0.1, C= 0.1
## - Fold08: degree=2, scale=0.1, C= 0.1
## + Fold08: degree=3, scale=0.1, C= 0.1
## - Fold08: degree=3, scale=0.1, C= 0.1
## + Fold08: degree=2, scale=1.0, C= 0.1
## - Fold08: degree=2, scale=1.0, C= 0.1
## + Fold08: degree=3, scale=1.0, C= 0.1
## - Fold08: degree=3, scale=1.0, C= 0.1
## + Fold08: degree=2, scale=0.1, C= 1.0
## - Fold08: degree=2, scale=0.1, C= 1.0
## + Fold08: degree=3, scale=0.1, C= 1.0
## - Fold08: degree=3, scale=0.1, C= 1.0
## + Fold08: degree=2, scale=1.0, C= 1.0
## - Fold08: degree=2, scale=1.0, C= 1.0
## + Fold08: degree=3, scale=1.0, C= 1.0
## - Fold08: degree=3, scale=1.0, C= 1.0
## + Fold08: degree=2, scale=0.1, C=10.0
## - Fold08: degree=2, scale=0.1, C=10.0
## + Fold08: degree=3, scale=0.1, C=10.0
## - Fold08: degree=3, scale=0.1, C=10.0
## + Fold08: degree=2, scale=1.0, C=10.0
## - Fold08: degree=2, scale=1.0, C=10.0
## + Fold08: degree=3, scale=1.0, C=10.0
## - Fold08: degree=3, scale=1.0, C=10.0
## + Fold09: degree=2, scale=0.1, C= 0.1
## - Fold09: degree=2, scale=0.1, C= 0.1
## + Fold09: degree=3, scale=0.1, C= 0.1
## - Fold09: degree=3, scale=0.1, C= 0.1
## + Fold09: degree=2, scale=1.0, C= 0.1
## - Fold09: degree=2, scale=1.0, C= 0.1
## + Fold09: degree=3, scale=1.0, C= 0.1
## - Fold09: degree=3, scale=1.0, C= 0.1
## + Fold09: degree=2, scale=0.1, C= 1.0
## - Fold09: degree=2, scale=0.1, C= 1.0
## + Fold09: degree=3, scale=0.1, C= 1.0
## - Fold09: degree=3, scale=0.1, C= 1.0
## + Fold09: degree=2, scale=1.0, C= 1.0
## - Fold09: degree=2, scale=1.0, C= 1.0
## + Fold09: degree=3, scale=1.0, C= 1.0
## - Fold09: degree=3, scale=1.0, C= 1.0
## + Fold09: degree=2, scale=0.1, C=10.0
## - Fold09: degree=2, scale=0.1, C=10.0
## + Fold09: degree=3, scale=0.1, C=10.0
## - Fold09: degree=3, scale=0.1, C=10.0
## + Fold09: degree=2, scale=1.0, C=10.0
## - Fold09: degree=2, scale=1.0, C=10.0
## + Fold09: degree=3, scale=1.0, C=10.0
## - Fold09: degree=3, scale=1.0, C=10.0
## + Fold10: degree=2, scale=0.1, C= 0.1
## - Fold10: degree=2, scale=0.1, C= 0.1
## + Fold10: degree=3, scale=0.1, C= 0.1
## - Fold10: degree=3, scale=0.1, C= 0.1
## + Fold10: degree=2, scale=1.0, C= 0.1
## - Fold10: degree=2, scale=1.0, C= 0.1
## + Fold10: degree=3, scale=1.0, C= 0.1
## - Fold10: degree=3, scale=1.0, C= 0.1
## + Fold10: degree=2, scale=0.1, C= 1.0
## - Fold10: degree=2, scale=0.1, C= 1.0
## + Fold10: degree=3, scale=0.1, C= 1.0
## - Fold10: degree=3, scale=0.1, C= 1.0
## + Fold10: degree=2, scale=1.0, C= 1.0
## - Fold10: degree=2, scale=1.0, C= 1.0
## + Fold10: degree=3, scale=1.0, C= 1.0
## - Fold10: degree=3, scale=1.0, C= 1.0
## + Fold10: degree=2, scale=0.1, C=10.0
## - Fold10: degree=2, scale=0.1, C=10.0
## + Fold10: degree=3, scale=0.1, C=10.0
## - Fold10: degree=3, scale=0.1, C=10.0
## + Fold10: degree=2, scale=1.0, C=10.0
## - Fold10: degree=2, scale=1.0, C=10.0
## + Fold10: degree=3, scale=1.0, C=10.0
## - Fold10: degree=3, scale=1.0, C=10.0
## Aggregating results
## Selecting tuning parameters
## Fitting degree = 2, scale = 0.1, C = 0.1 on full training set
## [1] "Mejores parámetros para Linear :"
## C
## 1 0.1
## [1] "Mejores parámetros para Radial :"
## sigma C
## 1 0.01 0.1
## [1] "Mejores parámetros para Polynomial :"
## degree scale C
## 1 2 0.1 0.1
##
## Call:
## summary.resamples(object = results)
##
## Models: Linear, Radial, Polynomial
## Number of resamples: 10
##
## Accuracy
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## AUC
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Kappa
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## logLoss
## Min. 1st Qu. Median Mean 3rd Qu.
## Linear 0.005093979 0.005228199 0.005358789 0.005364191 0.005493263
## Radial 0.003537352 0.003640286 0.003754005 0.003881610 0.003988805
## Polynomial 0.003062670 0.003195248 0.003616990 0.003739818 0.003866582
## Max. NA's
## Linear 0.005655705 0
## Radial 0.004633500 0
## Polynomial 0.005742285 0
##
## Mean_Balanced_Accuracy
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Detection_Rate
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0
## Radial 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0
## Polynomial 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0
##
## Mean_F1
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Neg_Pred_Value
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Pos_Pred_Value
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Precision
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Recall
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Sensitivity
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## Mean_Specificity
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 1 1 1 1 1 1 0
## Radial 1 1 1 1 1 1 0
## Polynomial 1 1 1 1 1 1 0
##
## prAUC
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## Linear 0.8712547 0.8758843 0.8819236 0.8828371 0.8914040 0.8925510 0
## Radial 0.8712547 0.8758843 0.8819236 0.8828371 0.8925510 0.8925510 0
## Polynomial 0.9140420 0.9140471 0.9161787 0.9172838 0.9205337 0.9241153 0
El resumen de los tres modelos SVM (Lineal, Radial y Polinomial) revela un rendimiento sorprendentemente perfecto en todas las métricas de clasificación evaluadas, incluyendo Accuracy, AUC, Kappa, y diversas medidas de precisión, recall y F1-score, con un valor de 1 en cada caso. El logLoss consistentemente bajo refuerza esta observación de predicciones altamente confiables.
## [1] "Matriz de Confusión para SVM Lineal:"
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Mediana Cara
## Barata 37 0 18
## Mediana 0 381 0
## Cara 0 0 0
##
## Overall Statistics
##
## Accuracy : 0.9587
## 95% CI : (0.9355, 0.9754)
## No Information Rate : 0.8739
## P-Value [Acc > NIR] : 1.087e-09
##
## Kappa : 0.8171
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Mediana Class: Cara
## Sensitivity 1.00000 1.0000 0.00000
## Specificity 0.95489 1.0000 1.00000
## Pos Pred Value 0.67273 1.0000 NaN
## Neg Pred Value 1.00000 1.0000 0.95872
## Prevalence 0.08486 0.8739 0.04128
## Detection Rate 0.08486 0.8739 0.00000
## Detection Prevalence 0.12615 0.8739 0.00000
## Balanced Accuracy 0.97744 1.0000 0.50000
## [1] "Matriz de Confusión para SVM Radial:"
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Mediana Cara
## Barata 0 0 0
## Mediana 37 381 18
## Cara 0 0 0
##
## Overall Statistics
##
## Accuracy : 0.8739
## 95% CI : (0.839, 0.9035)
## No Information Rate : 0.8739
## P-Value [Acc > NIR] : 0.5359
##
## Kappa : 0
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Mediana Class: Cara
## Sensitivity 0.00000 1.0000 0.00000
## Specificity 1.00000 0.0000 1.00000
## Pos Pred Value NaN 0.8739 NaN
## Neg Pred Value 0.91514 NaN 0.95872
## Prevalence 0.08486 0.8739 0.04128
## Detection Rate 0.00000 0.8739 0.00000
## Detection Prevalence 0.00000 1.0000 0.00000
## Balanced Accuracy 0.50000 0.5000 0.50000
## [1] "Matriz de Confusión para SVM Polinomial:"
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Mediana Cara
## Barata 0 0 0
## Mediana 0 0 0
## Cara 0 0 0
##
## Overall Statistics
##
## Accuracy : NaN
## 95% CI : (NA, NA)
## No Information Rate : NA
## P-Value [Acc > NIR] : NA
##
## Kappa : NaN
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Mediana Class: Cara
## Sensitivity NA NA NA
## Specificity NA NA NA
## Pos Pred Value NA NA NA
## Neg Pred Value NA NA NA
## Prevalence NaN NaN NaN
## Detection Rate NaN NaN NaN
## Detection Prevalence NaN NaN NaN
## Balanced Accuracy NA NA NA
El SVM Lineal fue el mejor modelo, alcanzando una precisión del 95.87% y un fuerte acuerdo (Kappa de 0.8171). Clasificó perfectamente la clase “Mediana” y razonablemente bien “Barata”, pero falló totalmente en detectar la clase “Cara”. A pesar de esta debilidad, el modelo demuestra ser confiable en general y claramente superior frente a los otros.
El SVM Radial, aunque logró un 87.39% de precisión, solo predijo la clase “Mediana” y falló completamente en “Barata” y “Cara”, evidenciado por su Kappa de 0. El SVM Polinomial no logró clasificar ningún dato, resultando en métricas NaN. Por tanto, el SVM Lineal es el modelo recomendado, aunque sería conveniente trabajar en mejorar la detección de la clase “Cara”.
Analisis de sobreajuste
## Resultados para el modelo SVM Lineal :
## Rendimiento en el conjunto de entrenamiento (Validación Cruzada):
## C logLoss AUC prAUC Accuracy Kappa Mean_F1 Mean_Sensitivity
## 1 0.1 0.005364191 1 0.8828371 1 1 1 1
## Mean_Specificity Mean_Pos_Pred_Value Mean_Neg_Pred_Value Mean_Precision
## 1 1 1 1 1
## Mean_Recall Mean_Detection_Rate Mean_Balanced_Accuracy logLossSD AUCSD
## 1 1 0.3333333 1 0.0001800735 0
## prAUCSD AccuracySD KappaSD Mean_F1SD Mean_SensitivitySD
## 1 0.008577379 0 0 0 0
## Mean_SpecificitySD Mean_Pos_Pred_ValueSD Mean_Neg_Pred_ValueSD
## 1 0 0 0
## Mean_PrecisionSD Mean_RecallSD Mean_Detection_RateSD Mean_Balanced_AccuracySD
## 1 0 0 0 0
##
## Matriz de Confusión en el conjunto de prueba:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Mediana Cara
## Barata 37 0 18
## Mediana 0 381 0
## Cara 0 0 0
##
## Overall Statistics
##
## Accuracy : 0.9587
## 95% CI : (0.9355, 0.9754)
## No Information Rate : 0.8739
## P-Value [Acc > NIR] : 1.087e-09
##
## Kappa : 0.8171
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Mediana Class: Cara
## Sensitivity 1.00000 1.0000 0.00000
## Specificity 0.95489 1.0000 1.00000
## Pos Pred Value 0.67273 1.0000 NaN
## Neg Pred Value 1.00000 1.0000 0.95872
## Prevalence 0.08486 0.8739 0.04128
## Detection Rate 0.08486 0.8739 0.00000
## Detection Prevalence 0.12615 0.8739 0.00000
## Balanced Accuracy 0.97744 1.0000 0.50000
##
## Métricas de rendimiento en el conjunto de prueba:
## Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull
## 9.587156e-01 8.170629e-01 9.355360e-01 9.753517e-01 8.738532e-01
## AccuracyPValue McnemarPValue
## 1.086936e-09 NaN
## Sensitivity Specificity Pos Pred Value Neg Pred Value Precision
## Class: Barata 1 0.9548872 0.6727273 1.0000000 0.6727273
## Class: Mediana 1 1.0000000 1.0000000 1.0000000 1.0000000
## Class: Cara 0 1.0000000 NaN 0.9587156 NA
## Recall F1 Prevalence Detection Rate Detection Prevalence
## Class: Barata 1 0.8043478 0.08486239 0.08486239 0.1261468
## Class: Mediana 1 1.0000000 0.87385321 0.87385321 0.8738532
## Class: Cara 0 NA 0.04128440 0.00000000 0.0000000
## Balanced Accuracy
## Class: Barata 0.9774436
## Class: Mediana 1.0000000
## Class: Cara 0.5000000
## Resultados para el modelo SVM Radial :
## Rendimiento en el conjunto de entrenamiento (Validación Cruzada):
## C sigma logLoss AUC prAUC Accuracy Kappa Mean_F1 Mean_Sensitivity
## 1 0.1 0.01 0.00388161 1 0.8828371 1 1 1 1
## Mean_Specificity Mean_Pos_Pred_Value Mean_Neg_Pred_Value Mean_Precision
## 1 1 1 1 1
## Mean_Recall Mean_Detection_Rate Mean_Balanced_Accuracy logLossSD AUCSD
## 1 1 0.3333333 1 0.0003788492 0
## prAUCSD AccuracySD KappaSD Mean_F1SD Mean_SensitivitySD
## 1 0.009516516 0 0 0 0
## Mean_SpecificitySD Mean_Pos_Pred_ValueSD Mean_Neg_Pred_ValueSD
## 1 0 0 0
## Mean_PrecisionSD Mean_RecallSD Mean_Detection_RateSD Mean_Balanced_AccuracySD
## 1 0 0 0 0
##
## Matriz de Confusión en el conjunto de prueba:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Barata Mediana Cara
## Barata 0 0 0
## Mediana 37 381 18
## Cara 0 0 0
##
## Overall Statistics
##
## Accuracy : 0.8739
## 95% CI : (0.839, 0.9035)
## No Information Rate : 0.8739
## P-Value [Acc > NIR] : 0.5359
##
## Kappa : 0
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Barata Class: Mediana Class: Cara
## Sensitivity 0.00000 1.0000 0.00000
## Specificity 1.00000 0.0000 1.00000
## Pos Pred Value NaN 0.8739 NaN
## Neg Pred Value 0.91514 NaN 0.95872
## Prevalence 0.08486 0.8739 0.04128
## Detection Rate 0.00000 0.8739 0.00000
## Detection Prevalence 0.00000 1.0000 0.00000
## Balanced Accuracy 0.50000 0.5000 0.50000
##
## Métricas de rendimiento en el conjunto de prueba:
## Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull
## 0.8738532 0.0000000 0.8389858 0.9035376 0.8738532
## AccuracyPValue McnemarPValue
## 0.5358605 NaN
## Sensitivity Specificity Pos Pred Value Neg Pred Value Precision
## Class: Barata 0 1 NaN 0.9151376 NA
## Class: Mediana 1 0 0.8738532 NaN 0.8738532
## Class: Cara 0 1 NaN 0.9587156 NA
## Recall F1 Prevalence Detection Rate Detection Prevalence
## Class: Barata 0 NA 0.08486239 0.0000000 0
## Class: Mediana 1 0.9326805 0.87385321 0.8738532 1
## Class: Cara 0 NA 0.04128440 0.0000000 0
## Balanced Accuracy
## Class: Barata 0.5
## Class: Mediana 0.5
## Class: Cara 0.5
## Resultados para el modelo SVM Polinomial :
## Rendimiento en el conjunto de entrenamiento (Validación Cruzada):
## degree scale C logLoss AUC prAUC Accuracy Kappa Mean_F1
## 1 2 0.1 0.1 0.003739818 1 0.9172838 1 1 1
## Mean_Sensitivity Mean_Specificity Mean_Pos_Pred_Value Mean_Neg_Pred_Value
## 1 1 1 1 1
## Mean_Precision Mean_Recall Mean_Detection_Rate Mean_Balanced_Accuracy
## 1 1 1 0.3333333 1
## logLossSD AUCSD prAUCSD AccuracySD KappaSD Mean_F1SD
## 1 0.0007857148 0 0.003893947 0 0 0
## Mean_SensitivitySD Mean_SpecificitySD Mean_Pos_Pred_ValueSD
## 1 0 0 0
## Mean_Neg_Pred_ValueSD Mean_PrecisionSD Mean_RecallSD Mean_Detection_RateSD
## 1 0 0 0 3.204938e-17
## Mean_Balanced_AccuracySD
## 1 0
##
## Matriz de Confusión en el conjunto de prueba:
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Caras Medianas
## Baratas 124 0 0
## Caras 0 63 0
## Medianas 0 0 1273
##
## Overall Statistics
##
## Accuracy : 1
## 95% CI : (0.9975, 1)
## No Information Rate : 0.8719
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 1
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Caras Class: Medianas
## Sensitivity 1.00000 1.00000 1.0000
## Specificity 1.00000 1.00000 1.0000
## Pos Pred Value 1.00000 1.00000 1.0000
## Neg Pred Value 1.00000 1.00000 1.0000
## Prevalence 0.08493 0.04315 0.8719
## Detection Rate 0.08493 0.04315 0.8719
## Detection Prevalence 0.08493 0.04315 0.8719
## Balanced Accuracy 1.00000 1.00000 1.0000
##
## Métricas de rendimiento en el conjunto de prueba:
## Accuracy Kappa AccuracyLower AccuracyUpper AccuracyNull
## 1.000000e+00 1.000000e+00 9.974766e-01 1.000000e+00 8.719178e-01
## AccuracyPValue McnemarPValue
## 1.242510e-87 NaN
## Sensitivity Specificity Pos Pred Value Neg Pred Value Precision
## Class: Baratas 1 1 1 1 1
## Class: Caras 1 1 1 1 1
## Class: Medianas 1 1 1 1 1
## Recall F1 Prevalence Detection Rate Detection Prevalence
## Class: Baratas 1 1 0.08493151 0.08493151 0.08493151
## Class: Caras 1 1 0.04315068 0.04315068 0.04315068
## Class: Medianas 1 1 0.87191781 0.87191781 0.87191781
## Balanced Accuracy
## Class: Baratas 1
## Class: Caras 1
## Class: Medianas 1
SVM Lineal: El modelo SVM Lineal muestra un rendimiento ligeramente inferior en el conjunto de prueba (aproximadamente 95.87% de precisión) en comparación con el rendimiento perfecto o casi perfecto observado durante la validación cruzada en el conjunto de entrenamiento. Esta pequeña disminución sugiere un ligero sobreajuste, donde el modelo aprendió algunos detalles específicos del conjunto de entrenamiento que no se generalizan perfectamente a los datos no vistos, especialmente para las categorías “Barata” y “Cara”. Para mitigar esto, se podrían explorar valores más altos para el parámetro de regularización C en el tuneGrid para imponer una mayor penalización a los errores de clasificación en el entrenamiento, lo que podría llevar a un modelo más simple con mejor capacidad de generalización. También se podría considerar la inclusión de más datos de entrenamiento si están disponibles.
SVM Radial: El modelo SVM Radial presenta una situación preocupante, con una precisión en el conjunto de prueba (87.39%) que coincide con la prevalencia de la clase mayoritaria (“Mediana”) y un Kappa de 0. Esto indica un sobreajuste severo o una muy mala generalización. El modelo parece haber aprendido los datos de entrenamiento de tal manera que no puede discriminar entre las clases en el conjunto de prueba, prediciendo casi todo como la clase dominante. Para lidiar con esto, se deberían explorar diferentes rangos de valores para los hiperparámetros C y sigma en el tuneGrid, posiblemente incluyendo valores más pequeños de C para aumentar la regularización y diferentes escalas de sigma para controlar la influencia de cada punto de entrenamiento. Si el problema persiste, podría ser que el kernel radial no sea el más adecuado para este problema con las variables predictoras disponibles.
SVM Polinomial: El modelo SVM Polinomial logra un rendimiento perfecto tanto en el conjunto de entrenamiento (según el análisis previo) como en el conjunto de prueba (100% de precisión y Kappa de 1). Esto indica una generalización ideal y un claro sobreajuste. Si bien este resultado es excelente, es demasiado ideal y perfecto, lo que hace que este modelo deba de volverse a hacer que no presente predicciones tan ajustadas.
Comparativa entre modelos
Los modelos organizados por precisión es el siguiente:
- SVM Polinomial (100%)
- SVM Lineal (95%)
- KNN (K=32) (94%)
- Árbol de Decisión (91%)
- Naive Bayes (78%)
El algoritmo que más tiempo tomó entrenar en mi computadora fue el KNN, el que menos tomó fue el Naive Bayes y el Árbol de decisión. El árbol de decisión se ve como un buen middle ground entre performance y precisión final del modelo.
Sin embargo, si lo que se busca es poder predictivo sin importar el costo, entonces la opción clara son los modelos SVM, no solo son los que mejor precisión han tenido de todos los modelos hasta ahora sino que además ni si quiera se demoraron más de 10s en entrenarse, lo que da un buen balance entre precisión y tiempo de entrenamiento.
Modelo que utiliza el precio directamente
## + Fold01: degree=1, scale=0.001, C=0.25
## - Fold01: degree=1, scale=0.001, C=0.25
## + Fold01: degree=2, scale=0.001, C=0.25
## - Fold01: degree=2, scale=0.001, C=0.25
## + Fold01: degree=3, scale=0.001, C=0.25
## - Fold01: degree=3, scale=0.001, C=0.25
## + Fold01: degree=1, scale=0.010, C=0.25
## - Fold01: degree=1, scale=0.010, C=0.25
## + Fold01: degree=2, scale=0.010, C=0.25
## - Fold01: degree=2, scale=0.010, C=0.25
## + Fold01: degree=3, scale=0.010, C=0.25
## - Fold01: degree=3, scale=0.010, C=0.25
## + Fold01: degree=1, scale=0.100, C=0.25
## - Fold01: degree=1, scale=0.100, C=0.25
## + Fold01: degree=2, scale=0.100, C=0.25
## - Fold01: degree=2, scale=0.100, C=0.25
## + Fold01: degree=3, scale=0.100, C=0.25
## - Fold01: degree=3, scale=0.100, C=0.25
## + Fold01: degree=1, scale=0.001, C=0.50
## - Fold01: degree=1, scale=0.001, C=0.50
## + Fold01: degree=2, scale=0.001, C=0.50
## - Fold01: degree=2, scale=0.001, C=0.50
## + Fold01: degree=3, scale=0.001, C=0.50
## - Fold01: degree=3, scale=0.001, C=0.50
## + Fold01: degree=1, scale=0.010, C=0.50
## - Fold01: degree=1, scale=0.010, C=0.50
## + Fold01: degree=2, scale=0.010, C=0.50
## - Fold01: degree=2, scale=0.010, C=0.50
## + Fold01: degree=3, scale=0.010, C=0.50
## - Fold01: degree=3, scale=0.010, C=0.50
## + Fold01: degree=1, scale=0.100, C=0.50
## - Fold01: degree=1, scale=0.100, C=0.50
## + Fold01: degree=2, scale=0.100, C=0.50
## - Fold01: degree=2, scale=0.100, C=0.50
## + Fold01: degree=3, scale=0.100, C=0.50
## - Fold01: degree=3, scale=0.100, C=0.50
## + Fold01: degree=1, scale=0.001, C=1.00
## - Fold01: degree=1, scale=0.001, C=1.00
## + Fold01: degree=2, scale=0.001, C=1.00
## - Fold01: degree=2, scale=0.001, C=1.00
## + Fold01: degree=3, scale=0.001, C=1.00
## - Fold01: degree=3, scale=0.001, C=1.00
## + Fold01: degree=1, scale=0.010, C=1.00
## - Fold01: degree=1, scale=0.010, C=1.00
## + Fold01: degree=2, scale=0.010, C=1.00
## - Fold01: degree=2, scale=0.010, C=1.00
## + Fold01: degree=3, scale=0.010, C=1.00
## - Fold01: degree=3, scale=0.010, C=1.00
## + Fold01: degree=1, scale=0.100, C=1.00
## - Fold01: degree=1, scale=0.100, C=1.00
## + Fold01: degree=2, scale=0.100, C=1.00
## - Fold01: degree=2, scale=0.100, C=1.00
## + Fold01: degree=3, scale=0.100, C=1.00
## - Fold01: degree=3, scale=0.100, C=1.00
## + Fold02: degree=1, scale=0.001, C=0.25
## - Fold02: degree=1, scale=0.001, C=0.25
## + Fold02: degree=2, scale=0.001, C=0.25
## - Fold02: degree=2, scale=0.001, C=0.25
## + Fold02: degree=3, scale=0.001, C=0.25
## - Fold02: degree=3, scale=0.001, C=0.25
## + Fold02: degree=1, scale=0.010, C=0.25
## - Fold02: degree=1, scale=0.010, C=0.25
## + Fold02: degree=2, scale=0.010, C=0.25
## - Fold02: degree=2, scale=0.010, C=0.25
## + Fold02: degree=3, scale=0.010, C=0.25
## - Fold02: degree=3, scale=0.010, C=0.25
## + Fold02: degree=1, scale=0.100, C=0.25
## - Fold02: degree=1, scale=0.100, C=0.25
## + Fold02: degree=2, scale=0.100, C=0.25
## - Fold02: degree=2, scale=0.100, C=0.25
## + Fold02: degree=3, scale=0.100, C=0.25
## - Fold02: degree=3, scale=0.100, C=0.25
## + Fold02: degree=1, scale=0.001, C=0.50
## - Fold02: degree=1, scale=0.001, C=0.50
## + Fold02: degree=2, scale=0.001, C=0.50
## - Fold02: degree=2, scale=0.001, C=0.50
## + Fold02: degree=3, scale=0.001, C=0.50
## - Fold02: degree=3, scale=0.001, C=0.50
## + Fold02: degree=1, scale=0.010, C=0.50
## - Fold02: degree=1, scale=0.010, C=0.50
## + Fold02: degree=2, scale=0.010, C=0.50
## - Fold02: degree=2, scale=0.010, C=0.50
## + Fold02: degree=3, scale=0.010, C=0.50
## - Fold02: degree=3, scale=0.010, C=0.50
## + Fold02: degree=1, scale=0.100, C=0.50
## - Fold02: degree=1, scale=0.100, C=0.50
## + Fold02: degree=2, scale=0.100, C=0.50
## - Fold02: degree=2, scale=0.100, C=0.50
## + Fold02: degree=3, scale=0.100, C=0.50
## - Fold02: degree=3, scale=0.100, C=0.50
## + Fold02: degree=1, scale=0.001, C=1.00
## - Fold02: degree=1, scale=0.001, C=1.00
## + Fold02: degree=2, scale=0.001, C=1.00
## - Fold02: degree=2, scale=0.001, C=1.00
## + Fold02: degree=3, scale=0.001, C=1.00
## - Fold02: degree=3, scale=0.001, C=1.00
## + Fold02: degree=1, scale=0.010, C=1.00
## - Fold02: degree=1, scale=0.010, C=1.00
## + Fold02: degree=2, scale=0.010, C=1.00
## - Fold02: degree=2, scale=0.010, C=1.00
## + Fold02: degree=3, scale=0.010, C=1.00
## - Fold02: degree=3, scale=0.010, C=1.00
## + Fold02: degree=1, scale=0.100, C=1.00
## - Fold02: degree=1, scale=0.100, C=1.00
## + Fold02: degree=2, scale=0.100, C=1.00
## - Fold02: degree=2, scale=0.100, C=1.00
## + Fold02: degree=3, scale=0.100, C=1.00
## - Fold02: degree=3, scale=0.100, C=1.00
## + Fold03: degree=1, scale=0.001, C=0.25
## - Fold03: degree=1, scale=0.001, C=0.25
## + Fold03: degree=2, scale=0.001, C=0.25
## - Fold03: degree=2, scale=0.001, C=0.25
## + Fold03: degree=3, scale=0.001, C=0.25
## - Fold03: degree=3, scale=0.001, C=0.25
## + Fold03: degree=1, scale=0.010, C=0.25
## - Fold03: degree=1, scale=0.010, C=0.25
## + Fold03: degree=2, scale=0.010, C=0.25
## - Fold03: degree=2, scale=0.010, C=0.25
## + Fold03: degree=3, scale=0.010, C=0.25
## - Fold03: degree=3, scale=0.010, C=0.25
## + Fold03: degree=1, scale=0.100, C=0.25
## - Fold03: degree=1, scale=0.100, C=0.25
## + Fold03: degree=2, scale=0.100, C=0.25
## - Fold03: degree=2, scale=0.100, C=0.25
## + Fold03: degree=3, scale=0.100, C=0.25
## - Fold03: degree=3, scale=0.100, C=0.25
## + Fold03: degree=1, scale=0.001, C=0.50
## - Fold03: degree=1, scale=0.001, C=0.50
## + Fold03: degree=2, scale=0.001, C=0.50
## - Fold03: degree=2, scale=0.001, C=0.50
## + Fold03: degree=3, scale=0.001, C=0.50
## - Fold03: degree=3, scale=0.001, C=0.50
## + Fold03: degree=1, scale=0.010, C=0.50
## - Fold03: degree=1, scale=0.010, C=0.50
## + Fold03: degree=2, scale=0.010, C=0.50
## - Fold03: degree=2, scale=0.010, C=0.50
## + Fold03: degree=3, scale=0.010, C=0.50
## - Fold03: degree=3, scale=0.010, C=0.50
## + Fold03: degree=1, scale=0.100, C=0.50
## - Fold03: degree=1, scale=0.100, C=0.50
## + Fold03: degree=2, scale=0.100, C=0.50
## - Fold03: degree=2, scale=0.100, C=0.50
## + Fold03: degree=3, scale=0.100, C=0.50
## - Fold03: degree=3, scale=0.100, C=0.50
## + Fold03: degree=1, scale=0.001, C=1.00
## - Fold03: degree=1, scale=0.001, C=1.00
## + Fold03: degree=2, scale=0.001, C=1.00
## - Fold03: degree=2, scale=0.001, C=1.00
## + Fold03: degree=3, scale=0.001, C=1.00
## - Fold03: degree=3, scale=0.001, C=1.00
## + Fold03: degree=1, scale=0.010, C=1.00
## - Fold03: degree=1, scale=0.010, C=1.00
## + Fold03: degree=2, scale=0.010, C=1.00
## - Fold03: degree=2, scale=0.010, C=1.00
## + Fold03: degree=3, scale=0.010, C=1.00
## - Fold03: degree=3, scale=0.010, C=1.00
## + Fold03: degree=1, scale=0.100, C=1.00
## - Fold03: degree=1, scale=0.100, C=1.00
## + Fold03: degree=2, scale=0.100, C=1.00
## - Fold03: degree=2, scale=0.100, C=1.00
## + Fold03: degree=3, scale=0.100, C=1.00
## - Fold03: degree=3, scale=0.100, C=1.00
## + Fold04: degree=1, scale=0.001, C=0.25
## - Fold04: degree=1, scale=0.001, C=0.25
## + Fold04: degree=2, scale=0.001, C=0.25
## - Fold04: degree=2, scale=0.001, C=0.25
## + Fold04: degree=3, scale=0.001, C=0.25
## - Fold04: degree=3, scale=0.001, C=0.25
## + Fold04: degree=1, scale=0.010, C=0.25
## - Fold04: degree=1, scale=0.010, C=0.25
## + Fold04: degree=2, scale=0.010, C=0.25
## - Fold04: degree=2, scale=0.010, C=0.25
## + Fold04: degree=3, scale=0.010, C=0.25
## - Fold04: degree=3, scale=0.010, C=0.25
## + Fold04: degree=1, scale=0.100, C=0.25
## - Fold04: degree=1, scale=0.100, C=0.25
## + Fold04: degree=2, scale=0.100, C=0.25
## - Fold04: degree=2, scale=0.100, C=0.25
## + Fold04: degree=3, scale=0.100, C=0.25
## - Fold04: degree=3, scale=0.100, C=0.25
## + Fold04: degree=1, scale=0.001, C=0.50
## - Fold04: degree=1, scale=0.001, C=0.50
## + Fold04: degree=2, scale=0.001, C=0.50
## - Fold04: degree=2, scale=0.001, C=0.50
## + Fold04: degree=3, scale=0.001, C=0.50
## - Fold04: degree=3, scale=0.001, C=0.50
## + Fold04: degree=1, scale=0.010, C=0.50
## - Fold04: degree=1, scale=0.010, C=0.50
## + Fold04: degree=2, scale=0.010, C=0.50
## - Fold04: degree=2, scale=0.010, C=0.50
## + Fold04: degree=3, scale=0.010, C=0.50
## - Fold04: degree=3, scale=0.010, C=0.50
## + Fold04: degree=1, scale=0.100, C=0.50
## - Fold04: degree=1, scale=0.100, C=0.50
## + Fold04: degree=2, scale=0.100, C=0.50
## - Fold04: degree=2, scale=0.100, C=0.50
## + Fold04: degree=3, scale=0.100, C=0.50
## - Fold04: degree=3, scale=0.100, C=0.50
## + Fold04: degree=1, scale=0.001, C=1.00
## - Fold04: degree=1, scale=0.001, C=1.00
## + Fold04: degree=2, scale=0.001, C=1.00
## - Fold04: degree=2, scale=0.001, C=1.00
## + Fold04: degree=3, scale=0.001, C=1.00
## - Fold04: degree=3, scale=0.001, C=1.00
## + Fold04: degree=1, scale=0.010, C=1.00
## - Fold04: degree=1, scale=0.010, C=1.00
## + Fold04: degree=2, scale=0.010, C=1.00
## - Fold04: degree=2, scale=0.010, C=1.00
## + Fold04: degree=3, scale=0.010, C=1.00
## - Fold04: degree=3, scale=0.010, C=1.00
## + Fold04: degree=1, scale=0.100, C=1.00
## - Fold04: degree=1, scale=0.100, C=1.00
## + Fold04: degree=2, scale=0.100, C=1.00
## - Fold04: degree=2, scale=0.100, C=1.00
## + Fold04: degree=3, scale=0.100, C=1.00
## - Fold04: degree=3, scale=0.100, C=1.00
## + Fold05: degree=1, scale=0.001, C=0.25
## - Fold05: degree=1, scale=0.001, C=0.25
## + Fold05: degree=2, scale=0.001, C=0.25
## - Fold05: degree=2, scale=0.001, C=0.25
## + Fold05: degree=3, scale=0.001, C=0.25
## - Fold05: degree=3, scale=0.001, C=0.25
## + Fold05: degree=1, scale=0.010, C=0.25
## - Fold05: degree=1, scale=0.010, C=0.25
## + Fold05: degree=2, scale=0.010, C=0.25
## - Fold05: degree=2, scale=0.010, C=0.25
## + Fold05: degree=3, scale=0.010, C=0.25
## - Fold05: degree=3, scale=0.010, C=0.25
## + Fold05: degree=1, scale=0.100, C=0.25
## - Fold05: degree=1, scale=0.100, C=0.25
## + Fold05: degree=2, scale=0.100, C=0.25
## - Fold05: degree=2, scale=0.100, C=0.25
## + Fold05: degree=3, scale=0.100, C=0.25
## - Fold05: degree=3, scale=0.100, C=0.25
## + Fold05: degree=1, scale=0.001, C=0.50
## - Fold05: degree=1, scale=0.001, C=0.50
## + Fold05: degree=2, scale=0.001, C=0.50
## - Fold05: degree=2, scale=0.001, C=0.50
## + Fold05: degree=3, scale=0.001, C=0.50
## - Fold05: degree=3, scale=0.001, C=0.50
## + Fold05: degree=1, scale=0.010, C=0.50
## - Fold05: degree=1, scale=0.010, C=0.50
## + Fold05: degree=2, scale=0.010, C=0.50
## - Fold05: degree=2, scale=0.010, C=0.50
## + Fold05: degree=3, scale=0.010, C=0.50
## - Fold05: degree=3, scale=0.010, C=0.50
## + Fold05: degree=1, scale=0.100, C=0.50
## - Fold05: degree=1, scale=0.100, C=0.50
## + Fold05: degree=2, scale=0.100, C=0.50
## - Fold05: degree=2, scale=0.100, C=0.50
## + Fold05: degree=3, scale=0.100, C=0.50
## - Fold05: degree=3, scale=0.100, C=0.50
## + Fold05: degree=1, scale=0.001, C=1.00
## - Fold05: degree=1, scale=0.001, C=1.00
## + Fold05: degree=2, scale=0.001, C=1.00
## - Fold05: degree=2, scale=0.001, C=1.00
## + Fold05: degree=3, scale=0.001, C=1.00
## - Fold05: degree=3, scale=0.001, C=1.00
## + Fold05: degree=1, scale=0.010, C=1.00
## - Fold05: degree=1, scale=0.010, C=1.00
## + Fold05: degree=2, scale=0.010, C=1.00
## - Fold05: degree=2, scale=0.010, C=1.00
## + Fold05: degree=3, scale=0.010, C=1.00
## - Fold05: degree=3, scale=0.010, C=1.00
## + Fold05: degree=1, scale=0.100, C=1.00
## - Fold05: degree=1, scale=0.100, C=1.00
## + Fold05: degree=2, scale=0.100, C=1.00
## - Fold05: degree=2, scale=0.100, C=1.00
## + Fold05: degree=3, scale=0.100, C=1.00
## - Fold05: degree=3, scale=0.100, C=1.00
## + Fold06: degree=1, scale=0.001, C=0.25
## - Fold06: degree=1, scale=0.001, C=0.25
## + Fold06: degree=2, scale=0.001, C=0.25
## - Fold06: degree=2, scale=0.001, C=0.25
## + Fold06: degree=3, scale=0.001, C=0.25
## - Fold06: degree=3, scale=0.001, C=0.25
## + Fold06: degree=1, scale=0.010, C=0.25
## - Fold06: degree=1, scale=0.010, C=0.25
## + Fold06: degree=2, scale=0.010, C=0.25
## - Fold06: degree=2, scale=0.010, C=0.25
## + Fold06: degree=3, scale=0.010, C=0.25
## - Fold06: degree=3, scale=0.010, C=0.25
## + Fold06: degree=1, scale=0.100, C=0.25
## - Fold06: degree=1, scale=0.100, C=0.25
## + Fold06: degree=2, scale=0.100, C=0.25
## - Fold06: degree=2, scale=0.100, C=0.25
## + Fold06: degree=3, scale=0.100, C=0.25
## - Fold06: degree=3, scale=0.100, C=0.25
## + Fold06: degree=1, scale=0.001, C=0.50
## - Fold06: degree=1, scale=0.001, C=0.50
## + Fold06: degree=2, scale=0.001, C=0.50
## - Fold06: degree=2, scale=0.001, C=0.50
## + Fold06: degree=3, scale=0.001, C=0.50
## - Fold06: degree=3, scale=0.001, C=0.50
## + Fold06: degree=1, scale=0.010, C=0.50
## - Fold06: degree=1, scale=0.010, C=0.50
## + Fold06: degree=2, scale=0.010, C=0.50
## - Fold06: degree=2, scale=0.010, C=0.50
## + Fold06: degree=3, scale=0.010, C=0.50
## - Fold06: degree=3, scale=0.010, C=0.50
## + Fold06: degree=1, scale=0.100, C=0.50
## - Fold06: degree=1, scale=0.100, C=0.50
## + Fold06: degree=2, scale=0.100, C=0.50
## - Fold06: degree=2, scale=0.100, C=0.50
## + Fold06: degree=3, scale=0.100, C=0.50
## - Fold06: degree=3, scale=0.100, C=0.50
## + Fold06: degree=1, scale=0.001, C=1.00
## - Fold06: degree=1, scale=0.001, C=1.00
## + Fold06: degree=2, scale=0.001, C=1.00
## - Fold06: degree=2, scale=0.001, C=1.00
## + Fold06: degree=3, scale=0.001, C=1.00
## - Fold06: degree=3, scale=0.001, C=1.00
## + Fold06: degree=1, scale=0.010, C=1.00
## - Fold06: degree=1, scale=0.010, C=1.00
## + Fold06: degree=2, scale=0.010, C=1.00
## - Fold06: degree=2, scale=0.010, C=1.00
## + Fold06: degree=3, scale=0.010, C=1.00
## - Fold06: degree=3, scale=0.010, C=1.00
## + Fold06: degree=1, scale=0.100, C=1.00
## - Fold06: degree=1, scale=0.100, C=1.00
## + Fold06: degree=2, scale=0.100, C=1.00
## - Fold06: degree=2, scale=0.100, C=1.00
## + Fold06: degree=3, scale=0.100, C=1.00
## - Fold06: degree=3, scale=0.100, C=1.00
## + Fold07: degree=1, scale=0.001, C=0.25
## - Fold07: degree=1, scale=0.001, C=0.25
## + Fold07: degree=2, scale=0.001, C=0.25
## - Fold07: degree=2, scale=0.001, C=0.25
## + Fold07: degree=3, scale=0.001, C=0.25
## - Fold07: degree=3, scale=0.001, C=0.25
## + Fold07: degree=1, scale=0.010, C=0.25
## - Fold07: degree=1, scale=0.010, C=0.25
## + Fold07: degree=2, scale=0.010, C=0.25
## - Fold07: degree=2, scale=0.010, C=0.25
## + Fold07: degree=3, scale=0.010, C=0.25
## - Fold07: degree=3, scale=0.010, C=0.25
## + Fold07: degree=1, scale=0.100, C=0.25
## - Fold07: degree=1, scale=0.100, C=0.25
## + Fold07: degree=2, scale=0.100, C=0.25
## - Fold07: degree=2, scale=0.100, C=0.25
## + Fold07: degree=3, scale=0.100, C=0.25
## - Fold07: degree=3, scale=0.100, C=0.25
## + Fold07: degree=1, scale=0.001, C=0.50
## - Fold07: degree=1, scale=0.001, C=0.50
## + Fold07: degree=2, scale=0.001, C=0.50
## - Fold07: degree=2, scale=0.001, C=0.50
## + Fold07: degree=3, scale=0.001, C=0.50
## - Fold07: degree=3, scale=0.001, C=0.50
## + Fold07: degree=1, scale=0.010, C=0.50
## - Fold07: degree=1, scale=0.010, C=0.50
## + Fold07: degree=2, scale=0.010, C=0.50
## - Fold07: degree=2, scale=0.010, C=0.50
## + Fold07: degree=3, scale=0.010, C=0.50
## - Fold07: degree=3, scale=0.010, C=0.50
## + Fold07: degree=1, scale=0.100, C=0.50
## - Fold07: degree=1, scale=0.100, C=0.50
## + Fold07: degree=2, scale=0.100, C=0.50
## - Fold07: degree=2, scale=0.100, C=0.50
## + Fold07: degree=3, scale=0.100, C=0.50
## - Fold07: degree=3, scale=0.100, C=0.50
## + Fold07: degree=1, scale=0.001, C=1.00
## - Fold07: degree=1, scale=0.001, C=1.00
## + Fold07: degree=2, scale=0.001, C=1.00
## - Fold07: degree=2, scale=0.001, C=1.00
## + Fold07: degree=3, scale=0.001, C=1.00
## - Fold07: degree=3, scale=0.001, C=1.00
## + Fold07: degree=1, scale=0.010, C=1.00
## - Fold07: degree=1, scale=0.010, C=1.00
## + Fold07: degree=2, scale=0.010, C=1.00
## - Fold07: degree=2, scale=0.010, C=1.00
## + Fold07: degree=3, scale=0.010, C=1.00
## - Fold07: degree=3, scale=0.010, C=1.00
## + Fold07: degree=1, scale=0.100, C=1.00
## - Fold07: degree=1, scale=0.100, C=1.00
## + Fold07: degree=2, scale=0.100, C=1.00
## - Fold07: degree=2, scale=0.100, C=1.00
## + Fold07: degree=3, scale=0.100, C=1.00
## - Fold07: degree=3, scale=0.100, C=1.00
## + Fold08: degree=1, scale=0.001, C=0.25
## - Fold08: degree=1, scale=0.001, C=0.25
## + Fold08: degree=2, scale=0.001, C=0.25
## - Fold08: degree=2, scale=0.001, C=0.25
## + Fold08: degree=3, scale=0.001, C=0.25
## - Fold08: degree=3, scale=0.001, C=0.25
## + Fold08: degree=1, scale=0.010, C=0.25
## - Fold08: degree=1, scale=0.010, C=0.25
## + Fold08: degree=2, scale=0.010, C=0.25
## - Fold08: degree=2, scale=0.010, C=0.25
## + Fold08: degree=3, scale=0.010, C=0.25
## - Fold08: degree=3, scale=0.010, C=0.25
## + Fold08: degree=1, scale=0.100, C=0.25
## - Fold08: degree=1, scale=0.100, C=0.25
## + Fold08: degree=2, scale=0.100, C=0.25
## - Fold08: degree=2, scale=0.100, C=0.25
## + Fold08: degree=3, scale=0.100, C=0.25
## - Fold08: degree=3, scale=0.100, C=0.25
## + Fold08: degree=1, scale=0.001, C=0.50
## - Fold08: degree=1, scale=0.001, C=0.50
## + Fold08: degree=2, scale=0.001, C=0.50
## - Fold08: degree=2, scale=0.001, C=0.50
## + Fold08: degree=3, scale=0.001, C=0.50
## - Fold08: degree=3, scale=0.001, C=0.50
## + Fold08: degree=1, scale=0.010, C=0.50
## - Fold08: degree=1, scale=0.010, C=0.50
## + Fold08: degree=2, scale=0.010, C=0.50
## - Fold08: degree=2, scale=0.010, C=0.50
## + Fold08: degree=3, scale=0.010, C=0.50
## - Fold08: degree=3, scale=0.010, C=0.50
## + Fold08: degree=1, scale=0.100, C=0.50
## - Fold08: degree=1, scale=0.100, C=0.50
## + Fold08: degree=2, scale=0.100, C=0.50
## - Fold08: degree=2, scale=0.100, C=0.50
## + Fold08: degree=3, scale=0.100, C=0.50
## - Fold08: degree=3, scale=0.100, C=0.50
## + Fold08: degree=1, scale=0.001, C=1.00
## - Fold08: degree=1, scale=0.001, C=1.00
## + Fold08: degree=2, scale=0.001, C=1.00
## - Fold08: degree=2, scale=0.001, C=1.00
## + Fold08: degree=3, scale=0.001, C=1.00
## - Fold08: degree=3, scale=0.001, C=1.00
## + Fold08: degree=1, scale=0.010, C=1.00
## - Fold08: degree=1, scale=0.010, C=1.00
## + Fold08: degree=2, scale=0.010, C=1.00
## - Fold08: degree=2, scale=0.010, C=1.00
## + Fold08: degree=3, scale=0.010, C=1.00
## - Fold08: degree=3, scale=0.010, C=1.00
## + Fold08: degree=1, scale=0.100, C=1.00
## - Fold08: degree=1, scale=0.100, C=1.00
## + Fold08: degree=2, scale=0.100, C=1.00
## - Fold08: degree=2, scale=0.100, C=1.00
## + Fold08: degree=3, scale=0.100, C=1.00
## - Fold08: degree=3, scale=0.100, C=1.00
## + Fold09: degree=1, scale=0.001, C=0.25
## - Fold09: degree=1, scale=0.001, C=0.25
## + Fold09: degree=2, scale=0.001, C=0.25
## - Fold09: degree=2, scale=0.001, C=0.25
## + Fold09: degree=3, scale=0.001, C=0.25
## - Fold09: degree=3, scale=0.001, C=0.25
## + Fold09: degree=1, scale=0.010, C=0.25
## - Fold09: degree=1, scale=0.010, C=0.25
## + Fold09: degree=2, scale=0.010, C=0.25
## - Fold09: degree=2, scale=0.010, C=0.25
## + Fold09: degree=3, scale=0.010, C=0.25
## - Fold09: degree=3, scale=0.010, C=0.25
## + Fold09: degree=1, scale=0.100, C=0.25
## - Fold09: degree=1, scale=0.100, C=0.25
## + Fold09: degree=2, scale=0.100, C=0.25
## - Fold09: degree=2, scale=0.100, C=0.25
## + Fold09: degree=3, scale=0.100, C=0.25
## - Fold09: degree=3, scale=0.100, C=0.25
## + Fold09: degree=1, scale=0.001, C=0.50
## - Fold09: degree=1, scale=0.001, C=0.50
## + Fold09: degree=2, scale=0.001, C=0.50
## - Fold09: degree=2, scale=0.001, C=0.50
## + Fold09: degree=3, scale=0.001, C=0.50
## - Fold09: degree=3, scale=0.001, C=0.50
## + Fold09: degree=1, scale=0.010, C=0.50
## - Fold09: degree=1, scale=0.010, C=0.50
## + Fold09: degree=2, scale=0.010, C=0.50
## - Fold09: degree=2, scale=0.010, C=0.50
## + Fold09: degree=3, scale=0.010, C=0.50
## - Fold09: degree=3, scale=0.010, C=0.50
## + Fold09: degree=1, scale=0.100, C=0.50
## - Fold09: degree=1, scale=0.100, C=0.50
## + Fold09: degree=2, scale=0.100, C=0.50
## - Fold09: degree=2, scale=0.100, C=0.50
## + Fold09: degree=3, scale=0.100, C=0.50
## - Fold09: degree=3, scale=0.100, C=0.50
## + Fold09: degree=1, scale=0.001, C=1.00
## - Fold09: degree=1, scale=0.001, C=1.00
## + Fold09: degree=2, scale=0.001, C=1.00
## - Fold09: degree=2, scale=0.001, C=1.00
## + Fold09: degree=3, scale=0.001, C=1.00
## - Fold09: degree=3, scale=0.001, C=1.00
## + Fold09: degree=1, scale=0.010, C=1.00
## - Fold09: degree=1, scale=0.010, C=1.00
## + Fold09: degree=2, scale=0.010, C=1.00
## - Fold09: degree=2, scale=0.010, C=1.00
## + Fold09: degree=3, scale=0.010, C=1.00
## - Fold09: degree=3, scale=0.010, C=1.00
## + Fold09: degree=1, scale=0.100, C=1.00
## - Fold09: degree=1, scale=0.100, C=1.00
## + Fold09: degree=2, scale=0.100, C=1.00
## - Fold09: degree=2, scale=0.100, C=1.00
## + Fold09: degree=3, scale=0.100, C=1.00
## - Fold09: degree=3, scale=0.100, C=1.00
## + Fold10: degree=1, scale=0.001, C=0.25
## - Fold10: degree=1, scale=0.001, C=0.25
## + Fold10: degree=2, scale=0.001, C=0.25
## - Fold10: degree=2, scale=0.001, C=0.25
## + Fold10: degree=3, scale=0.001, C=0.25
## - Fold10: degree=3, scale=0.001, C=0.25
## + Fold10: degree=1, scale=0.010, C=0.25
## - Fold10: degree=1, scale=0.010, C=0.25
## + Fold10: degree=2, scale=0.010, C=0.25
## - Fold10: degree=2, scale=0.010, C=0.25
## + Fold10: degree=3, scale=0.010, C=0.25
## - Fold10: degree=3, scale=0.010, C=0.25
## + Fold10: degree=1, scale=0.100, C=0.25
## - Fold10: degree=1, scale=0.100, C=0.25
## + Fold10: degree=2, scale=0.100, C=0.25
## - Fold10: degree=2, scale=0.100, C=0.25
## + Fold10: degree=3, scale=0.100, C=0.25
## - Fold10: degree=3, scale=0.100, C=0.25
## + Fold10: degree=1, scale=0.001, C=0.50
## - Fold10: degree=1, scale=0.001, C=0.50
## + Fold10: degree=2, scale=0.001, C=0.50
## - Fold10: degree=2, scale=0.001, C=0.50
## + Fold10: degree=3, scale=0.001, C=0.50
## - Fold10: degree=3, scale=0.001, C=0.50
## + Fold10: degree=1, scale=0.010, C=0.50
## - Fold10: degree=1, scale=0.010, C=0.50
## + Fold10: degree=2, scale=0.010, C=0.50
## - Fold10: degree=2, scale=0.010, C=0.50
## + Fold10: degree=3, scale=0.010, C=0.50
## - Fold10: degree=3, scale=0.010, C=0.50
## + Fold10: degree=1, scale=0.100, C=0.50
## - Fold10: degree=1, scale=0.100, C=0.50
## + Fold10: degree=2, scale=0.100, C=0.50
## - Fold10: degree=2, scale=0.100, C=0.50
## + Fold10: degree=3, scale=0.100, C=0.50
## - Fold10: degree=3, scale=0.100, C=0.50
## + Fold10: degree=1, scale=0.001, C=1.00
## - Fold10: degree=1, scale=0.001, C=1.00
## + Fold10: degree=2, scale=0.001, C=1.00
## - Fold10: degree=2, scale=0.001, C=1.00
## + Fold10: degree=3, scale=0.001, C=1.00
## - Fold10: degree=3, scale=0.001, C=1.00
## + Fold10: degree=1, scale=0.010, C=1.00
## - Fold10: degree=1, scale=0.010, C=1.00
## + Fold10: degree=2, scale=0.010, C=1.00
## - Fold10: degree=2, scale=0.010, C=1.00
## + Fold10: degree=3, scale=0.010, C=1.00
## - Fold10: degree=3, scale=0.010, C=1.00
## + Fold10: degree=1, scale=0.100, C=1.00
## - Fold10: degree=1, scale=0.100, C=1.00
## + Fold10: degree=2, scale=0.100, C=1.00
## - Fold10: degree=2, scale=0.100, C=1.00
## + Fold10: degree=3, scale=0.100, C=1.00
## - Fold10: degree=3, scale=0.100, C=1.00
## Aggregating results
## Selecting tuning parameters
## Fitting degree = 2, scale = 0.1, C = 0.25 on full training set
## Resultados para el modelo de regresion de Sale Price :
## Rendimiento en el conjunto de entrenamiento (Validación Cruzada):
## degree scale C RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 24 3 0.01 1 34204.45 0.8236895 21288.06 15649.61 0.134252 2328.721
##
## Rendimiento en el conjunto de prueba:
## RMSE Rsquared MAE
## 4.010407e+04 7.362592e-01 2.208610e+04
El modelo de regresión de arriba es un SVM polinomial entrenado con validación cruzada, el mejor R cuadrado encontrado es de 0.84 durante el entrenamiento, teniendo por hiperparámetros: * degree: 3 * scale: 0.1 * c: 0.25
Con la data de validación se obtuvieron resultados muy lamentables, llegando a 0.6023 el R cuadrado, lo cual es apenas un poco mejor a “tirar una moneda”, el RMSE es de 54 mil dólares, lo que significa que el precio generalmente tiene un rango de error de más/menos 54 mil dólares.
A qué creemos que se debe este cambio con respecto al clasificador SVM polinomial anterior que obtuvo básicamente una nota perfecta?
Creemos que esta diferencia se debe principalmente a la mayor especificidad del “SalePrice” con respecto a la categoría, lo que hace que el modelo simplemente sea uno mucho más complicado y con mayor probabilidad de fallo, puesto que el precio lo debe adivinar casi que exacto para tener una mejor nota, mientras que el modelo clasificador solamente tiene 3 opciones y no importa qué tan mal adivine el precio mientras no se salga de sus clasificaciones.
Conclusiones y Recomendaciones
En conclusión, el modelo SVM Polinomial fue el mejor tanto en accuracy, y se tarda un tiempo medio en entrenar. Hasta ahora ha probado ser el mejor predictor para clasificar una casa en alguna de las 3 categorías.
Nuestra principal recomendación es utilizar varios modelos, por ejemplo, se podría usar un modelo específicamente diseñado para clasificar casas, el SVM polinomial clasificador desarrollado con anterioridad podría ser un buen ejemplo. Luego se tendría 3 modelos especializados, cada uno para cada categoría de casa. Bajo esta arquitectura cada modelo se puede especializar en su área en específico y no tiene toda la interferencia de los demás datos, lo que podría llevar a muchos mejores resultados que los acá mostrados.
Modelos de Redes Neuronales
Modelos Básicos
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Medianas Caras
## Baratas 22 14 0
## Medianas 18 364 12
## Caras 0 2 7
##
## Overall Statistics
##
## Accuracy : 0.8952
## 95% CI : (0.8627, 0.9223)
## No Information Rate : 0.8656
## P-Value [Acc > NIR] : 0.03682
##
## Kappa : 0.5121
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Medianas Class: Caras
## Sensitivity 0.55000 0.9579 0.36842
## Specificity 0.96491 0.4915 0.99524
## Pos Pred Value 0.61111 0.9239 0.77778
## Neg Pred Value 0.95533 0.6444 0.97209
## Prevalence 0.09112 0.8656 0.04328
## Detection Rate 0.05011 0.8292 0.01595
## Detection Prevalence 0.08200 0.8975 0.02050
## Balanced Accuracy 0.75746 0.7247 0.68183
El modelo de red neuronal muestra una precisión del 89.75%, mostrando una buena capacidad de predicción. Al analizar la predicción por clase, se ve un excelente rendimiento prediciendo la categoria “Medianas”. Para las clases “Baratas” y “Caras” se ve que el modelo tiene más dificultad para identificar correctamente estas categorias.
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Medianas Caras
## Baratas 24 11 0
## Medianas 16 363 11
## Caras 0 6 8
##
## Overall Statistics
##
## Accuracy : 0.8998
## 95% CI : (0.8678, 0.9262)
## No Information Rate : 0.8656
## P-Value [Acc > NIR] : 0.01831
##
## Kappa : 0.5493
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Medianas Class: Caras
## Sensitivity 0.60000 0.9553 0.42105
## Specificity 0.97243 0.5424 0.98571
## Pos Pred Value 0.68571 0.9308 0.57143
## Neg Pred Value 0.96040 0.6531 0.97412
## Prevalence 0.09112 0.8656 0.04328
## Detection Rate 0.05467 0.8269 0.01822
## Detection Prevalence 0.07973 0.8884 0.03189
## Balanced Accuracy 0.78622 0.7488 0.70338
Este modelo con 10 neuronas ocultas muestra una ligera mejora en la predicción (89.98%). Se puede ver una mejora ligera en la predicción de la clase “Medianas”. Para este modelo solo se ve una ligera mejora para la predicción de la clase “Cara”, manteniendo la predicción de la variable “Barata” igual que en el modelo anterior.
Ambos modelos de red neuronal presentan un rendimiento general similar, con una precisión ligeramente superior (89.98%) en comparación con el modelo de 5 neuronas (89.75%). La mejora con el aumento de neuronas ocultas es modesta. A nivel de clase, el modelo con 10 neuronas muestra una ligera mejora en la sensibilidad para la clase “Medianas” y un mejor valor predictivo positivo y especificidad para la clase “Caras”, mientras que el rendimiento para la clase “Baratas” se mantiene igual en ambos modelos. En resumen, duplicar el número de neuronas ocultas resultó en una mejora ligera en el rendimiento general y en la predicción de ciertas clases.
Sobreajuste en modelos
## Accuracy en entrenamiento: 92.46 %
## Accuracy en prueba: 89.52 %
##
## ✅ No se detecta sobreajuste significativo.
Para el tuneo del modelo se hará de forma automatica, de estas formas se prueban diferentes combinaciones de parametros y se escoge la de mejor accuracy.
## Accuracy en entrenamiento: 93.93 %
## Accuracy en prueba: 89.98 %
##
## ✅ No se detecta sobreajuste significativo.
Se puede ver que ninguno de los modelos anteriormente presenta sobreajuste, permitiendonos mejorar el modelo haciendolo un tuneo a sus parametros.
## Neural Network
##
## 1021 samples
## 13 predictor
## 3 classes: 'Baratas', 'Medianas', 'Caras'
##
## No pre-processing
## Resampling: Cross-Validated (5 fold)
## Summary of sample sizes: 816, 817, 817, 817, 817
## Resampling results across tuning parameters:
##
## size decay Accuracy Kappa
## 3 0.000 0.8805213 0.4545419
## 3 0.001 0.8991440 0.5185017
## 3 0.010 0.8962028 0.4694783
## 3 0.100 0.9059732 0.5211054
## 5 0.000 0.9001004 0.5128527
## 5 0.001 0.8853993 0.4490088
## 5 0.010 0.8991153 0.5339570
## 5 0.100 0.9069536 0.5380267
## 10 0.000 0.8707174 0.4307542
## 10 0.001 0.8736394 0.4299116
## 10 0.010 0.8765854 0.4485217
## 10 0.100 0.8942181 0.4918354
## 15 0.000 0.8677618 0.4153033
## 15 0.001 0.8648446 0.4155425
## 15 0.010 0.8746150 0.4425330
## 15 0.100 0.8981349 0.5173514
##
## Accuracy was used to select the optimal model using the largest value.
## The final values used for the model were size = 5 and decay = 0.1.
## Confusion Matrix and Statistics
##
## Reference
## Prediction Baratas Medianas Caras
## Baratas 22 11 0
## Medianas 18 367 12
## Caras 0 2 7
##
## Overall Statistics
##
## Accuracy : 0.9021
## 95% CI : (0.8703, 0.9282)
## No Information Rate : 0.8656
## P-Value [Acc > NIR] : 0.01249
##
## Kappa : 0.5324
##
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: Baratas Class: Medianas Class: Caras
## Sensitivity 0.55000 0.9658 0.36842
## Specificity 0.97243 0.4915 0.99524
## Pos Pred Value 0.66667 0.9244 0.77778
## Neg Pred Value 0.95567 0.6905 0.97209
## Prevalence 0.09112 0.8656 0.04328
## Detection Rate 0.05011 0.8360 0.01595
## Detection Prevalence 0.07517 0.9043 0.02050
## Balanced Accuracy 0.76122 0.7287 0.68183
## LotArea YearBuilt GarageCars GrLivArea
## Min. :-1.0324 Min. :-3.38345 Min. :-2.3632 Min. :-2.2223
## 1st Qu.:-0.3246 1st Qu.:-0.60965 1st Qu.:-1.0272 1st Qu.:-0.7089
## Median :-0.1072 Median : 0.06689 Median : 0.3088 Median :-0.1051
## Mean : 0.0000 Mean : 0.00000 Mean : 0.0000 Mean : 0.0000
## 3rd Qu.: 0.1344 3rd Qu.: 0.98022 3rd Qu.: 0.3088 3rd Qu.: 0.5044
## Max. :17.4441 Max. : 1.28466 Max. : 2.9808 Max. : 7.7937
## SalePrice Category OverallQual.10 OverallQual.2
## Min. :-1.7777 Baratas : 84 Min. :0.00000 Min. :0.0000000
## 1st Qu.:-0.6390 Medianas:893 1st Qu.:0.00000 1st Qu.:0.0000000
## Median :-0.2387 Caras : 44 Median :0.00000 Median :0.0000000
## Mean : 0.0000 Mean :0.01273 Mean :0.0009794
## 3rd Qu.: 0.4117 3rd Qu.:0.00000 3rd Qu.:0.0000000
## Max. : 7.2177 Max. :1.00000 Max. :1.0000000
## OverallQual.3 OverallQual.4 OverallQual.5 OverallQual.6
## Min. :0.00000 Min. :0.00000 Min. :0.000 Min. :0.0000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.000 1st Qu.:0.0000
## Median :0.00000 Median :0.00000 Median :0.000 Median :0.0000
## Mean :0.01077 Mean :0.07738 Mean :0.286 Mean :0.2458
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:1.000 3rd Qu.:0.0000
## Max. :1.00000 Max. :1.00000 Max. :1.000 Max. :1.0000
## OverallQual.7 OverallQual.8 OverallQual.9
## Min. :0.0000 Min. :0.0000 Min. :0.00000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.00000
## Median :0.0000 Median :0.0000 Median :0.00000
## Mean :0.2125 Mean :0.1214 Mean :0.03036
## 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.00000
## Max. :1.0000 Max. :1.0000 Max. :1.00000
En la gráfica podemos ver que los mejores parámetros encontrados fue para un size de 5 junto a un decay de 0.1, es con estos parametros que se genera la matriz de confusión para obtener el accuracy del modelo.
El modelo ajustado muestra una ligera mejora en la precisión general (90.21%) respecto al anterior, especialmente en la clase “Medianas”, que alcanza una alta sensibilidad (96.6%) y precisión (92.4%). Sin embargo, las clases minoritarias como “Baratas” y “Caras” continúan presentando bajos niveles de sensibilidad (55.0% y 36.8%, respectivamente), lo que indica que el modelo tiene dificultades para identificarlas correctamente debido al desbalance en los datos. Aunque el ajuste de parámetros mejoró el rendimiento global y ciertos aspectos específicos, el modelo sigue sesgado hacia la clase dominante. En caso de que se quiera mejorar el modelo, lo que se podria hacer es rebalancear el dataset para tener una mejor representación de las clases minoritarias y asi mejorar su predicción en el modelo.
Ahora utilizaremos la variable SalePrice directamente.
Modelos Neuronales sobre SalePrice
## Warning: package 'keras' was built under R version 4.4.3
##
## Attaching package: 'keras'
## The following object is masked _by_ '.GlobalEnv':
##
## normalize
## Model 1 - MAE: 0.2335 0.3062
## Model 2 - MAE: 0.24 0.2909
Tienen una tendencia a la baja en su mae, no se vuelven a cruzar luego del inicio (en algunos casos nunca se cruzan) y el set de validación se encuentra siempre por encima del de entrenamiento. Por todas estas razones puedo firmar que realmente no existe overfitting en los modelos sino que realmente se están comportando como deberían.
De ambos modelos, el que mejor se comportó fue el segundo, ya que obtuvo un MAE de 0.27 en la data de validación! Lo que nos indica que se equivoca masomenos por 1/3 de una desviación estándar sobre el precio de la casa.
Mejora del modelo
Para mejorar el modelo podríamos intentar aumentar la cantidad de neuronas que tiene:
## Model 2 - MAE: 0.2511 0.3025
Si duplicamos la cantidad de neuronas dentro de cada capa intermedia realmente no se puede apreciar una mejora en el modelo, de hecho técnicamente empeora puesto que ahora las curvas tienden a separarse entre sí. Talvez le podemos dar más tiempo de entrenamiento…
## Model 2 - MAE: 0.3961 0.3833
Aumentando la cantidad de epoch solo se empeoró el estado de sobreajuste, la última solución que estoy dispuesto a probar es aumentar solamente la cantidad de neuronas de las capas 1 y 2.
## Model 2 - MAE: 0.2427 0.2992
El loss en el modelo ahora tiende a la alza en las epoch finales del entrenamiento, lo cual me indic que realmente no es una mejora, sino que en realidad estoy haciendo un poco peor al modelo al realizar este cambio, además las líneas de mae están más separadas entre sí que antes.
Por todo esto el mejor modelo sigue siendo entonces el segundo que realizamos en esta sección.
¿Cuál es el mejor modelo para predecir?
El mejor modelo para predecir categorías como se dijo en entregas anteriores fue el SVM polinomial, indiscutiblemente, aunque un contendiente cercano fue el de árboles de decisión principalmente debido a lo corto que fue su tiempo de entrenamiento y a los resultados decentes que brindó.
En cuanto a predicción de la variable objetivo de SalePrice creemos que el modelo de redes neuronales fue el que mejor resultados brindó puesto que el mejor de los modelos expuestos con anterioridad llegó a solamente 0.27% de la desviación estándar de error mientras que el de SVM fue mucho más alto.
Conclusiones
En conclusión una tabla comparativa de los modelos predictivos categóricos la podemos ver a continuación:
| Modelo | Accuracy | Tiempo de Entrenamiento | Extra |
|---|---|---|---|
| Bayes | 78% | Media | Fácilmente el peor de todos |
| Árboles de Decisión y Random Forest | 91% | Rápido | Decentemente preciso para su velocidad de entrenamiento. |
| KNN | 94% | Media | Muy preciso, tiempo moderado de entrenamiento. |
| Regresión Logística | 94% | Media | Igual al KNN aunque un poco más balanceado, no confunde las clases con menor representación tan seguido |
| Modelo SVM | 100% | Media-Lenta | El mejor en términos de precisión de todos los modelos |
Par determinar la categoría de precio a la que debe pertenecer una casa, recomendamos con una gran confianza le modelo SVM, puesto que ofrece una precisión casi perfect y un tiempo de entrenamiento decente.
Para los modelos predictivos de la variable SalePrice tenemos:
| Modelo | MAE |
|---|---|
| SVM | 54 mil dólares |
| Redes Neuronales | 0.27 desviaciones estándar o 21052.48 dólares |
El modelo de redes neuronales se equivoca con +- 21 mil dólares, lo cual es mucho más preciso que el de SVM. Por lo que aunque se tarda un poco más en entrenar, lo recomendamos simplemente por la mayor precisión que tiene.